1 | <?php |
||
12 | class OrbitronDev extends AbstractProvider |
||
13 | { |
||
14 | use BearerAuthorizationTrait; |
||
15 | |||
16 | /** |
||
17 | * {@inheritDoc} |
||
18 | * @see \League\OAuth2\Client\Provider\AbstractProvider::ACCESS_TOKEN_RESOURCE_OWNER_ID |
||
19 | */ |
||
20 | const ACCESS_TOKEN_RESOURCE_OWNER_ID = 'id'; |
||
21 | |||
22 | /** |
||
23 | * Returns the base URL for authorizing a client. |
||
24 | * |
||
25 | * Eg. https://oauth.service.com/authorize |
||
26 | * |
||
27 | * @return string |
||
28 | */ |
||
29 | 6 | public function getBaseAuthorizationUrl() |
|
33 | |||
34 | /** |
||
35 | * Returns the base URL for requesting an access token. |
||
36 | * |
||
37 | * Eg. https://oauth.service.com/token |
||
38 | * |
||
39 | * @param array $params |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 12 | public function getBaseAccessTokenUrl(array $params) |
|
47 | |||
48 | /** |
||
49 | * Returns the URL for requesting the resource owner's details. |
||
50 | * |
||
51 | * @param AccessToken $token |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
||
59 | |||
60 | /** |
||
61 | * Returns the default scopes used by this provider. |
||
62 | * |
||
63 | * This should only be the scopes that are required to request the details |
||
64 | * of the resource owner, rather than all the available scopes. |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | 4 | protected function getDefaultScopes() |
|
72 | |||
73 | /** |
||
74 | * Get the string used to separate scopes. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 6 | protected function getScopeSeparator() |
|
82 | |||
83 | /** |
||
84 | * Checks a provider response for errors. |
||
85 | * |
||
86 | * @throws IdentityProviderException |
||
87 | * |
||
88 | * @param ResponseInterface $response |
||
89 | * @param array|string $data Parsed response data |
||
90 | * |
||
91 | * @return void |
||
92 | */ |
||
93 | 10 | protected function checkResponse(ResponseInterface $response, $data) |
|
94 | { |
||
95 | 10 | if ($response->getStatusCode() >= 400) { |
|
96 | 4 | throw new IdentityProviderException( |
|
97 | 4 | isset($data['message']) ? $data['message'] : $response->getReasonPhrase(), |
|
98 | 4 | $response->getStatusCode(), |
|
99 | 4 | $response->getBody() |
|
100 | ); |
||
101 | } elseif (isset($data['error'])) { |
||
102 | throw new IdentityProviderException( |
||
103 | isset($data['error']) ? $data['error'] : $response->getReasonPhrase(), |
||
104 | $response->getStatusCode(), |
||
105 | $response->getBody() |
||
106 | ); |
||
107 | } |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Generates a resource owner object from a successful resource owner |
||
112 | * details request. |
||
113 | * |
||
114 | * @param array $response |
||
115 | * @param AccessToken $token |
||
116 | * |
||
117 | * @return ResourceOwnerInterface |
||
118 | */ |
||
119 | protected function createResourceOwner(array $response, AccessToken $token) |
||
123 | } |
||
124 |