trait ClientCredentialsGrant

Traits

Properties

protected OAuthConfig|null $oauthConfig

The immutable OAuth 2 configuration.

from  HasOAuthConfig

Methods

oauthConfig()

Get the OAuth 2 configuration.

defaultOAuthConfig()

Define the default OAuth 2 configuration.

array
parseOAuthTokenResponse(Response $response)

Parse the access token, expiry and data of a token response.

array|null
resolveOAuthScopes(mixed $scopes)

Resolve the scopes reported by the provider.

resolveOAuthExpiry(mixed $expiresIn)

Resolve an OAuth token expiry.

cachedAccessToken(array $scopes = [], string $scopeSeparator = ' ', string|null $store = null, callable|null $requestModifier = null, string $key = '')

Cache client-credentials tokens for this grant.

getAccessToken(array $scopes = [], string $scopeSeparator = ' ', bool $returnResponse = false, callable|null $requestModifier = null)

Request a client-credentials access token.

createOAuthAuthenticatorFromResponse(Response $response)

Create an OAuth authenticator from a token response.

createOAuthAuthenticator(string $accessToken, DateTimeImmutable|null $expiresAt = null, array|null $scopes = null)

Create an OAuth authenticator.

resolveAccessTokenRequest(OAuthConfig $oauthConfig, array $scopes = [], string $scopeSeparator = ' ')

Resolve the client-credentials request.

Details

in HasOAuthConfig at line 24
OAuthConfig oauthConfig()

Get the OAuth 2 configuration.

Return Value

OAuthConfig

in HasOAuthConfig at line 32
abstract protected OAuthConfig defaultOAuthConfig()

Define the default OAuth 2 configuration.

Return Value

OAuthConfig

protected array parseOAuthTokenResponse(Response $response)

Parse the access token, expiry and data of a token response.

Parameters

Response $response

Return Value

array

protected array|null resolveOAuthScopes(mixed $scopes)

Resolve the scopes reported by the provider.

Parameters

mixed $scopes

Return Value

array|null

protected CarbonImmutable|null resolveOAuthExpiry(mixed $expiresIn)

Resolve an OAuth token expiry.

Parameters

mixed $expiresIn

Return Value

CarbonImmutable|null

at line 34
CachedTokenAuthenticator cachedAccessToken(array $scopes = [], string $scopeSeparator = ' ', string|null $store = null, callable|null $requestModifier = null, string $key = '')

Cache client-credentials tokens for this grant.

Parameters

array $scopes
string $scopeSeparator
string|null $store
callable|null $requestModifier
string $key

Return Value

CachedTokenAuthenticator

at line 65
OAuthAuthenticator|Response getAccessToken(array $scopes = [], string $scopeSeparator = ' ', bool $returnResponse = false, callable|null $requestModifier = null)

Request a client-credentials access token.

Parameters

array $scopes
string $scopeSeparator
bool $returnResponse
callable|null $requestModifier

Return Value

OAuthAuthenticator|Response

at line 91
protected OAuthAuthenticator createOAuthAuthenticatorFromResponse(Response $response)

Create an OAuth authenticator from a token response.

Parameters

Response $response

Return Value

OAuthAuthenticator

at line 103
protected OAuthAuthenticator createOAuthAuthenticator(string $accessToken, DateTimeImmutable|null $expiresAt = null, array|null $scopes = null)

Create an OAuth authenticator.

Parameters

string $accessToken
DateTimeImmutable|null $expiresAt
array|null $scopes

Return Value

OAuthAuthenticator

at line 117
protected Request resolveAccessTokenRequest(OAuthConfig $oauthConfig, array $scopes = [], string $scopeSeparator = ' ')

Resolve the client-credentials request.

Parameters

OAuthConfig $oauthConfig
array $scopes
string $scopeSeparator

Return Value

Request