class OAuth2Middleware (View source)

Class OAuth2Middleware.

Properties

protected GrantTypeInterface $grantType Primary grant type.
protected GrantTypeInterface $refreshTokenGrantType Refresh token (secondary) grant type.
protected TokenRepositoryInterface $tokenRepository Token repository.
protected TokenInterface $token Token model.

Methods

getGrantType()

Get main grant type.

setGrantType(GrantTypeInterface $grantType)

Set main grant type.

getRefreshTokenGrantType()

Get refresh token grant type.

setRefreshTokenGrantType(GrantTypeInterface $refreshTokenGrantType)

Set refresh token grant type.

setToken(TokenInterface $token)

Set token.

getToken()

Get a valid access token.

setTokenRepository(TokenRepositoryInterface $tokenRepository)

Set token repository.

__construct(GrantTypeInterface $grantType, GrantTypeInterface $refreshTokenGrantType = null, TokenRepositoryInterface $tokenRepository = null)

Constructor.

__invoke(callable $handler)

Guzzle middleware invocation.

RequestInterface
signRequest(RequestInterface $request, TokenInterface $token)

Add auth headers.

requestNewToken()

Acquire a new access token from the oauth2 server.

Details

GrantTypeInterface getGrantType()

Get main grant type.

Return Value

GrantTypeInterface

setGrantType(GrantTypeInterface $grantType)

Set main grant type.

Parameters

GrantTypeInterface $grantType

GrantTypeInterface getRefreshTokenGrantType()

Get refresh token grant type.

Return Value

GrantTypeInterface

setRefreshTokenGrantType(GrantTypeInterface $refreshTokenGrantType)

Set refresh token grant type.

Parameters

GrantTypeInterface $refreshTokenGrantType

setToken(TokenInterface $token)

Set token.

Parameters

TokenInterface $token

TokenInterface|null getToken()

Get a valid access token.

Return Value

TokenInterface|null

Exceptions

TokenRequestException

setTokenRepository(TokenRepositoryInterface $tokenRepository)

Set token repository.

Parameters

TokenRepositoryInterface $tokenRepository

TokenRepositoryInterface getTokenRepository()

Get token repository.

__construct(GrantTypeInterface $grantType, GrantTypeInterface $refreshTokenGrantType = null, TokenRepositoryInterface $tokenRepository = null)

Constructor.

Parameters

GrantTypeInterface $grantType
GrantTypeInterface $refreshTokenGrantType
TokenRepositoryInterface $tokenRepository

Closure __invoke(callable $handler)

Guzzle middleware invocation.

Parameters

callable $handler

Return Value

Closure

protected RequestInterface signRequest(RequestInterface $request, TokenInterface $token)

Add auth headers.

Parameters

RequestInterface $request
TokenInterface $token

Return Value

RequestInterface

protected TokenInterface requestNewToken()

Acquire a new access token from the oauth2 server.

Return Value

TokenInterface

Exceptions

TokenRequestException