# media-cloud-sync/1.4.2/includes/sdk/s3/Aws/Token/BearerTokenAuthorization.php

Media Cloud Sync, version 1.4.2. 30 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/s3/Aws/Token/BearerTokenAuthorization.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/raw/includes/sdk/s3/Aws/Token/BearerTokenAuthorization.php
- Modified: 2025-08-17T07:06:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/s3/Aws/Token/BearerTokenAuthorization.php#L10-L20`.

```php
<?php

namespace Dudlewebs\WPMCS\s3\Aws\Token;

use InvalidArgumentException;
use Dudlewebs\WPMCS\s3\Psr\Http\Message\RequestInterface;
/**
 * Interface used to provide interchangeable strategies for adding authorization
 * to requests using the various AWS signature protocols.
 */
class BearerTokenAuthorization implements TokenAuthorization
{
    /**
     * Adds the specified token to a request by adding the required headers.
     *
     * @param RequestInterface     $request     Request to sign
     * @param TokenInterface       $token       Token
     *
     * @return RequestInterface Returns the modified request.
     */
    public function authorizeRequest(RequestInterface $request, TokenInterface $token)
    {
        if (empty($token) || empty($token->getToken())) {
            throw new InvalidArgumentException("Cannot authorize a request with an empty token");
        }
        $accessToken = $token->getToken();
        return $request->withHeader('Authorization', "Bearer {$accessToken}");
    }
}

```
