socialiteproviders/hubspot
HubSpot OAuth2 provider for Laravel Socialite. Adds HubSpot login and OAuth support to socialiteproviders, letting you authenticate users and access HubSpot CRM data with a simple, consistent Socialite driver.
Install Laravel Socialite plus the provider package you need. Each provider in the SocialiteProviders/Providers monorepo is published as its own Composer package:
composer require laravel/socialite socialiteproviders/hubspot
Look first at the provider-specific page (e.g. https://socialiteproviders.com/Hubspot/) for its required config and scopes, then at the monorepo README for the shared event-listener pattern.
Register the provider via the SocialiteWasCalled event. In Laravel 10 and earlier this typically lives in app/Providers/EventServiceProvider.php; in Laravel 11+ put it in AppServiceProvider::boot() or a dedicated provider listed in bootstrap/providers.php:
use SocialiteProviders\Manager\SocialiteWasCalled;
Event::listen(function (SocialiteWasCalled $event) {
$event->extendSocialite('hubspot', \SocialiteProviders\Hubspot\Provider::class);
});
Add credentials to config/services.php:
'hubspot' => [
'client_id' => env('HUBSPOT_CLIENT_ID'),
'client_secret' => env('HUBSPOT_CLIENT_SECRET'),
'redirect' => env('HUBSPOT_REDIRECT_URI'),
],
Then use the driver like any core Socialite provider:
return Socialite::driver('hubspot')->redirect();
// callback
$user = Socialite::driver('hubspot')->user();
First use case: adding an OAuth provider that Laravel Socialite doesn't ship with (HubSpot, Stripe Connect, etc.) without hand-writing an OAuth client. Patch 4.1.3 migrates the HubSpot provider to HubSpot's 2026-03 OAuth endpoints, so run composer update socialiteproviders/hubspot if HubSpot is in your stack.
->scopes([...]) or ->setScopes([...]); many providers have non-obvious defaults and vendor dashboards often require exact scope strings.Socialite::driver('hubspot')->stateless()->user() when you don't have a session/state store.$user->accessTokenResponseBody['refresh_token'] in the callback and refresh against the provider's token endpoint; verify per-provider support before relying on it.->with(['prompt' => 'consent']) (e.g. access_type=offline for Google-style providers).Socialite::driver('hubspot')->redirectUrl($url) where supported) or override services.<provider>.redirect at runtime.getAuthUrl, getTokenUrl, or mapUserToObject rather than forking the whole package.Socialite::shouldReceive('driver->user') or HTTP fakes for the token/user endpoints; don't hit real OAuth in CI.Laravel\Socialite\Two\InvalidStateException and GuzzleHttp\Exception\ClientException; surface a friendly error and restart the flow.composer show socialiteproviders/hubspot. The 4.1.3 change moves HubSpot OAuth to the 2026-03 endpoints; pinned older versions may still call deprecated endpoints and fail token exchange.php artisan config:clear after editing config/services.php; cached config will otherwise keep stale credentials or redirect URIs.services.php.Socialite::driver('...') matches the first argument to extendSocialite, and that the listener is registered in the current environment.EventServiceProvider; register the listener in AppServiceProvider::boot() or add a custom provider to bootstrap/providers.php.composer.json and skim provider changelogs before upgrades; patch releases like 4.1.3 are usually safe but can still change vendor endpoint behavior.vendor/.How can I help you explore Laravel packages today?