SocialiteProviders / Providers

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

Laravel Passport fails to return approved scopes #1229

Closed zorenkonte closed 4 months ago

zorenkonte commented 4 months ago

Laravel Passport is not returning approved scopes, unlike other providers such as GitHub and Google.

When logging the response in the user method, the response is:

array (
  'token_type' => 'Bearer',
  'expires_in' => 31536000,
  'access_token' => 'access_token',
  'refresh_token' => 'refresh_token',
) 

As a result, setApprovedScopes($this->parseApprovedScopes($response)) consistently returns null.

Steps to Reproduce:

  1. Redirect call

    Socialite::driver('laravelpassport')
                ->scopes(['user:email'])
                ->stateless()
                ->redirect()->getTargetUrl()
  2. Callback call

    Socialite::driver('laravelpassport')->stateless()->user()

The expected behavior is for the approved scopes to match those requested during authorization, as observed with other providers.

image

Screenshots

  1. Laravel Passport Response (Scopes are Empty)

    image
  2. GitHub Response (Scopes are Returned).

    // Result if you log the response of GitHub in the user() method. It returns 'scope' property.
    array (
    'access_token' => 'token',
    'token_type' => 'bearer',
    'scope' => 'user:email',
    )  
image
atymic commented 4 months ago

Is this not an issue with socialite not sending the approved scopes back, not with the socialite provider. Maybe PR to socialite to include scopes in reply?