Class OAuth2ResourceOwnerPasswordCredentialsGrant
java.lang.Object
com.linecorp.armeria.client.auth.oauth2.OAuth2ResourceOwnerPasswordCredentialsGrant
- All Implemented Interfaces:
OAuth2AuthorizationGrant
An implementation of OAuth 2.0 Resource Owner Password Credentials Grant flow to obtain Access Token,
as per [RFC6749], Section 4.3.
Implements Access Token loading, storing, obtaining and refreshing.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new builder forOAuth2ResourceOwnerPasswordCredentialsGrant
.Issues anOAuth 2.0 Access Token
and cache it in memory and returns the cached one until the token is considered valid.
-
Method Details
-
builder
public static OAuth2ResourceOwnerPasswordCredentialsGrantBuilder builder(WebClient accessTokenEndpoint, String accessTokenEndpointPath) Creates a new builder forOAuth2ResourceOwnerPasswordCredentialsGrant
.- Parameters:
accessTokenEndpoint
- AWebClient
to facilitate an Access Token request. Must correspond to the Access Token endpoint of the OAuth 2 system.accessTokenEndpointPath
- A URI path that corresponds to the Access Token endpoint of the
-
getAccessToken
Issues anOAuth 2.0 Access Token
and cache it in memory and returns the cached one until the token is considered valid. It automatically refreshes the cached token once it's considered expired and returns the refreshed one.Renewing a token is guaranteed to be atomic even though the method is invoked by multiple threads.
It optionally tries to load an access token from
AbstractOAuth2AuthorizationGrantBuilder.fallbackTokenProvider(Supplier)
orAbstractOAuth2AuthorizationGrantBuilder.fallbackTokenProvider(Supplier)
which supposedly gets one by querying to a longer term storage, before it makes a request to the authorization server.One may choose to provide a hook which gets executed every time a token is issued or refreshed from the authorization server to store the renewed token to a longer term storage via
AbstractOAuth2AuthorizationGrantBuilder.newTokenConsumer(Consumer)
orAbstractOAuth2AuthorizationGrantBuilder.newTokenConsumer(Consumer)
.- Specified by:
getAccessToken
in interfaceOAuth2AuthorizationGrant
-