@@ -19,12 +19,13 @@ abstract class AbstractProvider extends BaseProvider implements ProviderInterfac
19
19
protected $ credentialsResponseBody ;
20
20
21
21
/**
22
- * @param string $providerName
22
+ * @param string $providerName
23
+ *
23
24
* @return string
24
25
*/
25
26
public static function serviceContainerKey ($ providerName )
26
27
{
27
- return SocialiteWasCalled::SERVICE_CONTAINER_PREFIX . $ providerName ;
28
+ return SocialiteWasCalled::SERVICE_CONTAINER_PREFIX . $ providerName ;
28
29
}
29
30
30
31
/**
@@ -50,15 +51,16 @@ public function user()
50
51
}
51
52
52
53
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 ));
56
57
}
57
58
58
59
/**
59
60
* Get the access token from the token response body.
60
61
*
61
- * @param array $body
62
+ * @param array $body
63
+ *
62
64
* @return string
63
65
*/
64
66
protected function parseAccessToken ($ body )
@@ -69,7 +71,8 @@ protected function parseAccessToken($body)
69
71
/**
70
72
* Get the refresh token from the token response body.
71
73
*
72
- * @param array $body
74
+ * @param array $body
75
+ *
73
76
* @return string
74
77
*/
75
78
protected function parseRefreshToken ($ body )
@@ -80,7 +83,8 @@ protected function parseRefreshToken($body)
80
83
/**
81
84
* Get the expires in from the token response body.
82
85
*
83
- * @param array $body
86
+ * @param array $body
87
+ *
84
88
* @return string
85
89
*/
86
90
protected function parseExpiresIn ($ body )
@@ -91,11 +95,22 @@ protected function parseExpiresIn($body)
91
95
/**
92
96
* Get the approved scopes from the token response body.
93
97
*
94
- * @param array $body
98
+ * @param array $body
99
+ *
95
100
* @return array
96
101
*/
97
102
protected function parseApprovedScopes ($ body )
98
103
{
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
+
99
114
return explode ($ this ->scopeSeparator , Arr::get ($ body , 'scope ' , '' ));
100
115
}
101
116
}
0 commit comments