commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
lib
commercetools-base
src
Client
OAuth2Handler.php
1
<?php
2
3
declare(strict_types=1);
9
namespace
Commercetools\Client
;
10
11
use Psr\Cache\CacheItemInterface;
12
use Psr\Cache\CacheItemPoolInterface;
13
use Psr\Http\Message\RequestInterface;
14
15
class
OAuth2Handler
16
{
18
private
$provider;
19
24
public
function
__construct
(
TokenProvider
$provider)
25
{
26
$this->provider = $provider;
27
}
28
29
public
function
__invoke
(RequestInterface $request, array $options = []): RequestInterface
30
{
31
return
$request->withHeader(
'Authorization'
, $this->
getAuthorizationHeader
());
32
}
33
34
public
function
getAuthorizationHeader
(): string
35
{
36
return
'Bearer '
. $this->provider->getToken()->getValue();
37
}
38
39
public
function
refreshToken
():
Token
40
{
41
return
$this->provider->refreshToken();
42
}
43
}
Commercetools\Client\OAuth2Handler
Definition
OAuth2Handler.php:16
Commercetools\Client\OAuth2Handler\__invoke
__invoke(RequestInterface $request, array $options=[])
Definition
OAuth2Handler.php:29
Commercetools\Client\OAuth2Handler\getAuthorizationHeader
getAuthorizationHeader()
Definition
OAuth2Handler.php:34
Commercetools\Client\OAuth2Handler\refreshToken
refreshToken()
Definition
OAuth2Handler.php:39
Commercetools\Client\OAuth2Handler\__construct
__construct(TokenProvider $provider)
Definition
OAuth2Handler.php:24
Commercetools\Client\Token
Definition
Token.php:16
Commercetools\Client\TokenProvider
Definition
TokenProvider.php:13
Commercetools\Client
Definition
AnonymousFlowTokenProvider.php:5
Generated by
1.9.8