SocialiteProviders / Providers

A Collection of Providers for Laravel Socialite
https://socialiteproviders.com
MIT License
487 stars 435 forks source link

HubSpot redirect without specifying scope throws an error #1188

Closed sebastiansulinski closed 3 months ago

sebastiansulinski commented 3 months ago

It appears that the usage instructions need updating as just by calling Socialite::driver('hubspot')->redirect(); will eventually return the following error:

Couldn’t complete the connection An invalid scope name was provided. Please contact the app developer.

To resolve the issue you have to use setScopes before calling redirect i.e.

return Socialite::driver('hubspot')
        ->setScopes(config('services.hubspot.scopes'))
        ->redirect();

I've listed scopes with the original configuration:

'hubspot' => [
    'client_id' => env('HUBSPOT_CLIENT_ID'),
    'client_secret' => env('HUBSPOT_CLIENT_SECRET'),
    'redirect' => env('HUBSPOT_REDIRECT_URI', env('APP_URL').'/auth/callback'),
    'scopes' => env('HUBSPOT_SCOPES', ['crm.objects.contacts.read']),
],