PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / Token / BearerTokenAuthorization.php
transferito / vendor / aws / aws-sdk-php / src / Token Last commit date
BearerTokenAuthorization.php 11 months ago ParsesIniTrait.php 11 months ago RefreshableTokenProviderInterface.php 11 months ago SsoToken.php 11 months ago SsoTokenProvider.php 11 months ago Token.php 11 months ago TokenAuthorization.php 11 months ago TokenInterface.php 11 months ago TokenProvider.php 11 months ago
BearerTokenAuthorization.php
34 lines
1 <?php
2 namespace Aws\Token;
3
4 use InvalidArgumentException;
5 use Psr\Http\Message\RequestInterface;
6
7 /**
8 * Interface used to provide interchangeable strategies for adding authorization
9 * to requests using the various AWS signature protocols.
10 */
11 class BearerTokenAuthorization implements TokenAuthorization
12 {
13 /**
14 * Adds the specified token to a request by adding the required headers.
15 *
16 * @param RequestInterface $request Request to sign
17 * @param TokenInterface $token Token
18 *
19 * @return RequestInterface Returns the modified request.
20 */
21 public function authorizeRequest(
22 RequestInterface $request,
23 TokenInterface $token
24 ) {
25 if (empty($token) || empty($token->getToken())) {
26 throw new InvalidArgumentException(
27 "Cannot authorize a request with an empty token"
28 );
29 }
30 $accessToken = $token->getToken();
31 return $request->withHeader('Authorization', "Bearer {$accessToken}");
32 }
33 }
34