Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Auth Laravel Package

google/auth

Official Google Auth Library for PHP provides OAuth 2.0 authorization and authentication for Google and Cloud APIs. It implements Application Default Credentials (ADC) to help applications obtain credentials and securely call APIs, with easy Composer installation.

View on GitHub
Deep Wiki
Context7

Google Auth Library for PHP

Frequently asked questions about Auth
How do I install google/auth in a Laravel project using Composer?
Run composer require google/auth in your Laravel project root. The package is a standard Composer library, so no Laravel-specific service provider is auto-discovered. You can then use its classes like Google\Auth\ApplicationDefaultCredentials directly or wrap them in a custom service provider.
Does google/auth provide a Laravel service provider or facade?
No, google/auth does not include a native Laravel service provider or facade. You need to manually bootstrap the library, typically by creating a custom service provider that binds a configured Guzzle client with Google Auth middleware. This gives you control over credential loading and caching within Laravel's container.
How do I use Application Default Credentials (ADC) with google/auth in Laravel?
Set the GOOGLE_APPLICATION_CREDENTIALS environment variable in your .env file to point to your service account JSON key, or rely on the metadata server when running on Google Cloud. Then call ApplicationDefaultCredentials::getCredentials($scope) in your code. In Laravel, you can load the path via config() and avoid committing the key file to version control.
Can I use google/auth for Google Sign-In (user authentication) in Laravel?
google/auth supports OAuth 2.0 user credentials and ID tokens, but it is not a drop-in Laravel Guard for Google Sign-In. For user login flows, Laravel Socialite with the socialiteproviders/google package is usually simpler. Use google/auth when you need low-level control over OAuth 2.0 tokens or when calling Google APIs on behalf of a user.
How does google/auth handle token expiry and refresh in Laravel?
The library includes middleware that automatically refreshes expired access tokens using the refresh token or service account credentials. However, you should still handle authentication exceptions in your Laravel app, for example by retrying failed API calls with exponential backoff. The Guzzle middleware stack can be configured to fetch new tokens as needed.
Is google/auth compatible with Laravel's HTTP client and Guzzle?
google/auth integrates with Guzzle, which Laravel also uses under the hood. You typically create a Guzzle client with the Google Auth middleware and use it for Google API calls instead of Laravel's Http facade. Check Guzzle version compatibility early, as the package supports specific Guzzle major versions.
How can I cache Google OAuth tokens in Laravel with google/auth?
google/auth supports PSR-6 caching, so you can pass a Laravel Cache adapter (e.g., Redis or file-based) to its credential fetchers. This avoids fetching new tokens on every request. Configure the cache pool in your custom service provider and set appropriate TTLs based on token lifetime.
Does google/auth work with Workload Identity Federation in Laravel?
Yes, google/auth supports Workload Identity Federation for keyless authentication from AWS, Azure, or other identity providers. You must configure the federated identity pool and provider in Google Cloud IAM, then use the library's credential source to exchange external tokens. This is ideal for Laravel apps running outside Google Cloud that need to avoid service account keys.
What are the alternatives to google/auth for Google API authentication in Laravel?
For user authentication (Google Sign-In), Laravel Socialite with socialiteproviders/google is more integrated. For service-to-service Google Cloud API calls, google/auth is the official and recommended library. Other options like google/apiclient bundle google/auth and add API-specific clients, which may be overkill if you only need auth.
How do I test google/auth integration in a Laravel application?
Use Google's fake credentials or mock the ApplicationDefaultCredentials and middleware in your tests. Laravel's HTTP fake can intercept Guzzle requests if you inject the client. For integration tests, set GOOGLE_APPLICATION_CREDENTIALS to a test service account with limited scopes and verify token caching and error handling.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo