1 | <?php |
||
11 | final class Authentication |
||
12 | { |
||
13 | /** |
||
14 | * Function to create a Request object for obtaining a new token from the API |
||
15 | * |
||
16 | * @var callable |
||
17 | */ |
||
18 | private $getTokenRequestFunc; |
||
19 | |||
20 | /** |
||
21 | * Private constructor to safeguard undeclared functions |
||
22 | * |
||
23 | * @param callable $getTokenRequestFunc Function to create a Request object for obtaining a new token from the API |
||
24 | */ |
||
25 | private function __construct(callable $getTokenRequestFunc) |
||
29 | |||
30 | /** |
||
31 | * Creates a new instance of Authentication for Client Credentials grant type |
||
32 | * |
||
33 | * @param string $clientId The oauth client id |
||
34 | * @param string $clientSecret The oauth client secret |
||
35 | * @param string $refreshResource The refresh token resource of the API |
||
36 | * Only needed since apigee doesnt use the token resource that is in the oauth2 spec |
||
37 | * |
||
38 | * @return \DominionEnterprises\Api\Authentication |
||
39 | */ |
||
40 | public static function createClientCredentials( |
||
78 | |||
79 | /** |
||
80 | * Creates a new instance of Authentication for Owner Credentials grant type |
||
81 | * |
||
82 | * @param string $clientId The oauth client id |
||
83 | * @param string $clientSecret The oauth client secret |
||
84 | * @param string $username The oauth username |
||
85 | * @param string $password The oauth password |
||
86 | * @param string $refreshResource The refresh token resource of the API |
||
87 | * Only needed since apigee doesnt use the token resource that is in the oauth2 spec |
||
88 | * |
||
89 | * @return \DominionEnterprises\Api\Authentication |
||
90 | */ |
||
91 | public static function createOwnerCredentials( |
||
139 | |||
140 | /** |
||
141 | * Extracts an access token from the given API response |
||
142 | * |
||
143 | * @param \DominionEnterprises\Api\Response $response The API response containing the access token |
||
144 | * |
||
145 | * @return array Array containing the access token, refresh token and expires timestamp |
||
146 | */ |
||
147 | public static function parseTokenResponse(Response $response) |
||
158 | |||
159 | /** |
||
160 | * Creates a Request object for obtaining a new token from the API |
||
161 | * |
||
162 | * @param string $baseUrl The base url of the API |
||
163 | * @param string $refreshToken The refresh token of the API |
||
164 | * |
||
165 | * @return \DominionEnterprises\Api\Request |
||
166 | */ |
||
167 | public function getTokenRequest($baseUrl, $refreshToken) |
||
174 | |||
175 | /** |
||
176 | * Build a refresh token request |
||
177 | * |
||
178 | * @param string $baseUrl API base url |
||
179 | * @param string $clientId The client id |
||
180 | * @param string $clientSecret The client secret |
||
181 | * @param string $refreshResource The refresh token resource of the API |
||
182 | * Only needed since apigee doesnt use the token resource that is in the oauth2 spec |
||
183 | * @param string $refreshToken The refresh token of the API |
||
184 | * |
||
185 | * @return \DominionEnterprises\Api\Request The built token refresh request |
||
186 | */ |
||
187 | private static function getRefreshTokenRequest( |
||
211 | } |
||
212 |