Download the PHP package impression/laravel-google-passport-oauth without Composer

On this page you can find all versions of the php package impression/laravel-google-passport-oauth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-google-passport-oauth

Laravel Google Passport OAuth

Exchange Google OAuth access tokens for Laravel Passport personal access tokens. Enables seamless authentication from external applications (like better-chatbot) to your Laravel MCP server.

Features

Installation

Step 1: Install via Composer

Step 2: Publish Configuration

This creates config/google-oauth.php with sensible defaults.

Step 3: Set Environment Variables

Add to .env:

Step 4: Ensure Users Table Has Required Columns

If you need to store Google user IDs, add a migration:

Run migrations:

MCP OAuth 2.1 Registry Setup

This package supports OAuth 2.1 MCP HTTP Registry integration, allowing organizations to register protected resource metadata (PRM), authorization servers, and callback URLs for Alexis discovery. End users still sign in separately via their MCP connections (PKCE); org-level metadata is static and managed server-side.

Step 1: Publish MCP Migrations

Step 2: Set MCP Environment Variables

Add to .env:

Step 3: Run Migrations

This creates the mcp_oauth_connections table for storing org-level OAuth metadata.

Step 4: Register MCP Routes (Optional)

If you want to expose MCP endpoints in your parent app, update routes/api.php or routes/web.php:

Configuration

The package exposes configuration in config/google-oauth.php:

Column Mapping

If your users table uses different column names:

Domain Whitelist

Restrict authentication to specific email domains:

Only users with email addresses ending in these domains can authenticate. Leave empty/null to allow all domains.

Usage

Google OAuth Token Exchange (Existing Flow)

Authentication Flow

  1. External app (e.g., chatbot) obtains Google OAuth token from user
  2. External app sends token to your Laravel endpoint: POST /oauth/google-token
  3. Your package validates token with Google, finds user by email
  4. Your package issues Passport personal access token
  5. External app uses Passport token for subsequent API calls

HTTP Endpoint

POST /oauth/google-token

Request

Parameters:

Success Response (200 OK)

Use the access_token as a Bearer token in subsequent API requests:

Error Responses

400 Bad Request — Validation failed

401 Unauthorized — Token invalid, expired, or user not found

Other 401 errors:

503 Service Unavailable — Google API error

MCP OAuth 2.1 Registry Flow (New)

The MCP OAuth 2.1 flow allows organizations to register OAuth metadata for protected resource discovery. Organizations authenticate via either Google OAuth or fallback to parent app authentication, then register their OAuth 2.1 server details.

Authentication Flow

  1. Organization user is already authenticated in parent app (Laravel session)
  2. Organization user calls MCP endpoints without Google token (fallback to parent auth)
  3. Package middleware checks parent app session via configured guard
  4. Package issues Passport token for the authenticated user
  5. Organization visits confirmation page to review and register OAuth metadata
  6. Organization submits OAuth 2.1 metadata (PRM, authorization server URL, callback URL)
  7. Package stores metadata in mcp_oauth_connections table
  8. Alexis queries discovery endpoint to find registered OAuth configurations

MCP Token Exchange Endpoint

POST /oauth/mcp/token

This endpoint accepts both Google tokens and relies on parent app authentication.

Request (with Google token):
Request (fallback to parent app auth):
Success Response (200 OK)

MCP Confirmation Endpoint

GET /oauth/mcp/confirm

Shows existing MCP OAuth connections and prompts for new metadata.

Request
Success Response (200 OK)

MCP Connection Registration Endpoint

POST /oauth/mcp/connections

Register a new OAuth 2.1 connection for the organization.

Request

Parameters:

Success Response (201 Created)

Error Responses

401 Unauthorized

422 Unprocessable Entity — Validation failed

Integrating with Parent Laravel Application

To integrate this package as a sub-package in a larger Laravel application:

1. Install and Configure

2. Set Environment Variables

3. Register Routes in Parent App

In your parent app's routes/api.php:

4. Access MCP Models in Your App

5. Share User Model Configuration

Ensure your parent app's User model is properly configured:

6. Trusted Proxies (If Behind Load Balancer)

If your parent app is behind a load balancer, configure config/trustedproxy.php to properly detect authenticated sessions.


User Provisioning

Users must exist in your database before authenticating. The package does not auto-create users to prevent account enumeration attacks.

Provisioning Workflow

  1. Add user to database (via admin panel, bulk import, or migration):

  2. User authenticates via POST /oauth/google-token
  3. Package validates email matches (finds user)
  4. Package issues Passport token

Pre-provisioning at Scale

For bulk onboarding:

Security Considerations

Production Checklist

How It Works

  1. No token storage — Tokens validated in-memory, never persisted
  2. Server-side refresh — If token expired but refresh token provided, package refreshes silently
  3. Email-based lookup — User identity determined by email (not Google ID)
  4. Pre-provisioning only — Prevents account enumeration
  5. Signed Passport tokens — Subsequent API calls verified with Passport

Configuration Per Application

Each Laravel app using this package can customize the configuration independently:

MCP Server (config/google-oauth.php):

Internal App (config/google-oauth.php):

Partner Portal (config/google-oauth.php):

Testing

Running Tests

Test Coverage

Writing Integration Tests

In your app, add integration tests:

Quality Checks

The package includes code quality tools:

All quality gates pass:

Troubleshooting

"User not found" (401)

"Domain not allowed" (401)

"Token expired" (401)

"Service unavailable" (503)

Tests Failing

API Reference

GoogleTokenValidator

Validates Google OAuth tokens and handles refresh logic.

UserSyncResolver

Finds users by email with domain whitelist enforcement.

Exceptions

All exceptions extend GoogleOAuthException:

License

MIT

Contributing

Contributions welcome! Please ensure:

Support

For issues and questions, please open an issue on GitHub or contact the Impression team.


All versions of laravel-google-passport-oauth with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^11.0 || ^12.0
laravel/passport Version ^12.0 || ^13.0
laravel/socialite Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package impression/laravel-google-passport-oauth contains the following files

Loading the files please wait ...