Skip to content

Commit dbedc1e

Browse files
committed
fix: set approved scopes
1 parent 6dd81fc commit dbedc1e

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"require": {
3333
"php": "^7.2 || ^8.0",
3434
"illuminate/support": "^6.0 || ^7.0 || ^8.0",
35-
"laravel/socialite": "~4.0 || ~5.0"
35+
"laravel/socialite": "^5.5"
3636
},
3737
"require-dev": {
3838
"mockery/mockery": "^1.2",

src/OAuth2/AbstractProvider.php

+24-9
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ abstract class AbstractProvider extends BaseProvider implements ProviderInterfac
1919
protected $credentialsResponseBody;
2020

2121
/**
22-
* @param string $providerName
22+
* @param string $providerName
23+
*
2324
* @return string
2425
*/
2526
public static function serviceContainerKey($providerName)
2627
{
27-
return SocialiteWasCalled::SERVICE_CONTAINER_PREFIX.$providerName;
28+
return SocialiteWasCalled::SERVICE_CONTAINER_PREFIX . $providerName;
2829
}
2930

3031
/**
@@ -50,15 +51,16 @@ public function user()
5051
}
5152

5253
return $user->setToken($token)
53-
->setRefreshToken($this->parseRefreshToken($response))
54-
->setExpiresIn($this->parseExpiresIn($response))
55-
->setApprovedScopes($this->parseApprovedScopes($response));
54+
->setRefreshToken($this->parseRefreshToken($response))
55+
->setExpiresIn($this->parseExpiresIn($response))
56+
->setApprovedScopes($this->parseApprovedScopes($response));
5657
}
5758

5859
/**
5960
* Get the access token from the token response body.
6061
*
61-
* @param array $body
62+
* @param array $body
63+
*
6264
* @return string
6365
*/
6466
protected function parseAccessToken($body)
@@ -69,7 +71,8 @@ protected function parseAccessToken($body)
6971
/**
7072
* Get the refresh token from the token response body.
7173
*
72-
* @param array $body
74+
* @param array $body
75+
*
7376
* @return string
7477
*/
7578
protected function parseRefreshToken($body)
@@ -80,7 +83,8 @@ protected function parseRefreshToken($body)
8083
/**
8184
* Get the expires in from the token response body.
8285
*
83-
* @param array $body
86+
* @param array $body
87+
*
8488
* @return string
8589
*/
8690
protected function parseExpiresIn($body)
@@ -91,11 +95,22 @@ protected function parseExpiresIn($body)
9195
/**
9296
* Get the approved scopes from the token response body.
9397
*
94-
* @param array $body
98+
* @param array $body
99+
*
95100
* @return array
96101
*/
97102
protected function parseApprovedScopes($body)
98103
{
104+
$scopesRaw = Arr::get($body, 'scope', null);
105+
106+
if (!is_array($scopesRaw) && !is_string($scopesRaw)) {
107+
return [];
108+
}
109+
110+
if (is_array($scopesRaw)) {
111+
return $scopesRaw;
112+
}
113+
99114
return explode($this->scopeSeparator, Arr::get($body, 'scope', ''));
100115
}
101116
}

0 commit comments

Comments
 (0)