1 | <?php |
||
23 | trait AccessTokenAuthorizationTrait |
||
24 | { |
||
25 | use AccessTokenTrait; |
||
26 | |||
27 | /** |
||
28 | * @param RequestInterface $request |
||
29 | * @return RequestInterface |
||
30 | * @throws \yii\base\InvalidConfigException |
||
31 | */ |
||
32 | public function prepareAuthorizationRequest( |
||
42 | |||
43 | /** |
||
44 | * @param RequestInterface $request |
||
45 | * @return RequestInterface |
||
46 | * @throws \yii\base\InvalidConfigException |
||
47 | */ |
||
48 | protected function addAuthorizationHeader(RequestInterface $request): RequestInterface |
||
55 | |||
56 | /** |
||
57 | * @param ResponseInterface $response |
||
58 | * @param RequestInterface $request |
||
59 | * @param callable $runner |
||
60 | * @return ResponseInterface |
||
61 | * @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException |
||
62 | * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException |
||
63 | * @throws \yii\base\InvalidConfigException |
||
64 | */ |
||
65 | public function handleAuthorizationResponse( |
||
81 | |||
82 | /** |
||
83 | * @param ResponseInterface $response |
||
84 | * @return bool |
||
85 | */ |
||
86 | protected function responseIsExpiredToken(ResponseInterface $response): bool |
||
98 | |||
99 | /** |
||
100 | * @param RequestInterface $request |
||
101 | * @param ResponseInterface $response |
||
102 | * @param callable|null $next |
||
103 | * @return mixed |
||
104 | * @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException |
||
105 | * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException |
||
106 | * @throws \yii\base\InvalidConfigException |
||
107 | */ |
||
108 | protected function refreshAndRetry(RequestInterface $request, ResponseInterface $response, callable $next = null) |
||
126 | |||
127 | /** |
||
128 | * @param AccessTokenInterface $accessToken |
||
129 | * @param AccessTokenInterface $refreshToken |
||
130 | * @return bool |
||
131 | * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException |
||
132 | */ |
||
133 | protected function saveRefreshToken(AccessTokenInterface $accessToken, AccessTokenInterface $refreshToken): bool |
||
141 | |||
142 | /** |
||
143 | * @param array $error |
||
144 | * |
||
145 | * This is an example of the error |
||
146 | * [ |
||
147 | * 'status' => 'error', |
||
148 | * 'message' => 'This oauth-token (TOKEN_STRING) is expired! expiresAt: 1530045454360, now: 1530114086081', |
||
149 | * 'correlationId' => '1a45b07b-e8ba-41d5-8a85-508f1fdd3246', |
||
150 | * 'requestId' => '302880bcbf2c8727850c536b70254015' |
||
151 | * ] |
||
152 | * |
||
153 | * @return bool |
||
154 | */ |
||
155 | private function hasSessionExpired(array $error): bool |
||
170 | } |
||
171 |