1 | <?php |
||
11 | class BaseProvider extends AbstractProvider |
||
12 | { |
||
13 | /** |
||
14 | * Returns the base URL for authorizing a client. |
||
15 | * |
||
16 | * @return string |
||
17 | */ |
||
18 | 1 | public function getBaseAuthorizationUrl() |
|
22 | |||
23 | /** |
||
24 | * Returns the base URL for requesting an access token. |
||
25 | * |
||
26 | * Eg. https://oauth.service.com/token |
||
27 | * |
||
28 | * @param array $params |
||
29 | * @return string |
||
30 | */ |
||
31 | 3 | public function getBaseAccessTokenUrl(array $params) |
|
35 | |||
36 | /** |
||
37 | * Returns the URL for requesting the resource owner's details. |
||
38 | * |
||
39 | * @param AccessToken $token |
||
40 | * @return string |
||
41 | */ |
||
42 | 2 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
46 | |||
47 | /** |
||
48 | * Returns the default scopes used by this provider. |
||
49 | * |
||
50 | * This should only be the scopes that are required to request the details |
||
51 | * of the resource owner, rather than all the available scopes. |
||
52 | * |
||
53 | * @return string[] |
||
54 | */ |
||
55 | 1 | protected function getDefaultScopes() |
|
59 | |||
60 | /** |
||
61 | * Checks a provider response for errors. |
||
62 | * |
||
63 | * @throws IdentityProviderException |
||
64 | * @param ResponseInterface $response |
||
65 | * @param array|string $data Parsed response data |
||
66 | * @return void |
||
67 | */ |
||
68 | 3 | protected function checkResponse(ResponseInterface $response, $data) |
|
69 | { |
||
70 | 3 | if (isset($data['error'])) { |
|
71 | 1 | throw new IdentityProviderException( |
|
72 | 1 | $data['error'] ?: $response->getReasonPhrase(), |
|
73 | 1 | $response->getStatusCode(), |
|
74 | 1 | $response->getBody() |
|
75 | 1 | ); |
|
76 | } |
||
77 | 2 | } |
|
78 | |||
79 | /** |
||
80 | * Generates a resource owner object from a successful resource owner |
||
81 | * details request. |
||
82 | * |
||
83 | * @param array $response |
||
84 | * @param AccessToken $token |
||
85 | * @return ResourceOwnerInterface |
||
86 | */ |
||
87 | 1 | protected function createResourceOwner(array $response, AccessToken $token) |
|
91 | |||
92 | /** |
||
93 | * Returns the authorization headers used by this provider. |
||
94 | * |
||
95 | * @param mixed|null $token Either a string or an access token instance |
||
96 | * @return array |
||
97 | */ |
||
98 | 1 | public function getAuthorizationHeaders($token = null) |
|
102 | |||
103 | /** |
||
104 | * Returns the string that should be used to separate scopes when building |
||
105 | * the URL for requesting an access token. |
||
106 | * |
||
107 | * @return string Scope separator |
||
108 | */ |
||
109 | 1 | protected function getScopeSeparator() |
|
113 | } |
||
114 |