Closed nickbeen closed 7 months ago
Refreshing tokens with Twitch will result in a TypeError. Socialite expects the scope to be returned as a string, but Twitch will return the scope in an array.
string
array
Use the scope array directly instead of using explode().
explode()
Socialite::driver('twitch')->refreshToken($refreshToken);
Example response:
{ "access_token": "1ssjqsqfy6bads1ws7m03gras79zfr", "refresh_token": "eyJfMzUtNDU0OC4MWYwLTQ5MDY5ODY4NGNlMSJ9%asdfasdf=", "scope": [ "channel:read:subscriptions", "channel:manage:polls" ], "token_type": "bearer" }
Result:
TypeError explode(): Argument #2 ($string) must be of type string, array given at vendor/laravel/socialite/src/Two/AbstractProvider.php:357 353▕ return new Token( 354▕ Arr::get($response, 'access_token'), 355▕ Arr::get($response, 'refresh_token'), 356▕ Arr::get($response, 'expires_in'), ➜ 357▕ explode($this->scopeSeparator, Arr::get($response, 'scope', '')) 358▕ ); 359▕ } 360▕ 361▕ /**
Refreshing tokens with Twitch will result in a TypeError. Socialite expects the scope to be returned as a
string
, but Twitch will return the scope in anarray
.Fix error
Use the scope array directly instead of using
explode()
.Reproduce error
Example response:
Result: