Class TokenRequest.Builder
- java.lang.Object
-
- net.openid.appauth.TokenRequest.Builder
-
- Enclosing class:
- TokenRequest
public static final class TokenRequest.Builder extends Object
Creates instances ofTokenRequest
.
-
-
Constructor Summary
Constructors Constructor Description Builder(AuthorizationServiceConfiguration configuration, String clientId)
Creates a token request builder with the specified mandatory properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenRequest
build()
Produces aTokenRequest
instance, if all necessary values have been provided.TokenRequest.Builder
setAdditionalParameters(Map<String,String> additionalParameters)
Specifies an additional set of parameters to be sent as part of the request.TokenRequest.Builder
setAuthorizationCode(String authorizationCode)
Specifies the authorization code for the request.TokenRequest.Builder
setClientId(String clientId)
Specifies the client ID for the token request, which must not be null or empty.TokenRequest.Builder
setCodeVerifier(String codeVerifier)
Specifies the code verifier for an authorization code exchange request.TokenRequest.Builder
setConfiguration(AuthorizationServiceConfiguration configuration)
Specifies the authorization service configuration for the request, which must not be null or empty.TokenRequest.Builder
setGrantType(String grantType)
Specifies the grant type for the request, which must not be null or empty.TokenRequest.Builder
setNonce(String nonce)
Specifies the (optional) nonce for the current session.TokenRequest.Builder
setRedirectUri(Uri redirectUri)
Specifies the redirect URI for the request.TokenRequest.Builder
setRefreshToken(String refreshToken)
Specifies the refresh token for the request.TokenRequest.Builder
setScope(String scope)
Specifies the encoded scope string, which is a space-delimited set of case-sensitive scope identifiers.TokenRequest.Builder
setScopes(Iterable<String> scopes)
Specifies the set of case-sensitive scopes.TokenRequest.Builder
setScopes(String... scopes)
Specifies the set of case-sensitive scopes.
-
-
-
Constructor Detail
-
Builder
public Builder(@NonNull AuthorizationServiceConfiguration configuration, @NonNull String clientId)
Creates a token request builder with the specified mandatory properties.
-
-
Method Detail
-
setConfiguration
@NonNull public TokenRequest.Builder setConfiguration(@NonNull AuthorizationServiceConfiguration configuration)
Specifies the authorization service configuration for the request, which must not be null or empty.
-
setClientId
@NonNull public TokenRequest.Builder setClientId(@NonNull String clientId)
Specifies the client ID for the token request, which must not be null or empty.
-
setNonce
@NonNull public TokenRequest.Builder setNonce(@Nullable String nonce)
Specifies the (optional) nonce for the current session.
-
setGrantType
@NonNull public TokenRequest.Builder setGrantType(@NonNull String grantType)
Specifies the grant type for the request, which must not be null or empty.
-
setRedirectUri
@NonNull public TokenRequest.Builder setRedirectUri(@Nullable Uri redirectUri)
Specifies the redirect URI for the request.This is required for authorization code exchanges, but otherwise optional. If specified, the redirect URI must have a scheme.
-
setScope
@NonNull public TokenRequest.Builder setScope(@Nullable String scope)
Specifies the encoded scope string, which is a space-delimited set of case-sensitive scope identifiers.Replaces any previously specified scope.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 3.3 https://tools.ietf.org/html/rfc6749#section-3.3”
-
setScopes
@NonNull public TokenRequest.Builder setScopes(String... scopes)
Specifies the set of case-sensitive scopes.Replaces any previously specified set of scopes. Individual scope strings cannot be null or empty.
Scopes specified here are used to obtain a “down-scoped” access token, where the set of scopes specified must be a subset of those already granted in previous requests.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 3.3 https://tools.ietf.org/html/rfc6749#section-3.3”
,“The OAuth 2.0 Authorization Framework (RFC 6749), Section 6 https://tools.ietf.org/html/rfc6749#section-6”
-
setScopes
@NonNull public TokenRequest.Builder setScopes(@Nullable Iterable<String> scopes)
Specifies the set of case-sensitive scopes.Replaces any previously specified set of scopes. Individual scope strings cannot be null or empty.
Scopes specified here are used to obtain a “down-scoped” access token, where the set of scopes specified must be a subset of those already granted in previous requests.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 3.3 https://tools.ietf.org/html/rfc6749#section-3.3”
,“The OAuth 2.0 Authorization Framework (RFC 6749), Section 6 https://tools.ietf.org/html/rfc6749#section-6”
-
setAuthorizationCode
@NonNull public TokenRequest.Builder setAuthorizationCode(@Nullable String authorizationCode)
Specifies the authorization code for the request.If provided, the authorization code must not be empty.
Specifying an authorization code normally implies that this is a request to exchange this authorization code for one or more tokens. If this is not intended, the grant type should be explicitly set.
-
setRefreshToken
@NonNull public TokenRequest.Builder setRefreshToken(@Nullable String refreshToken)
Specifies the refresh token for the request.If a non-null value is provided, it must not be empty.
Specifying a refresh token normally implies that this is a request to exchange the refresh token for a new token. If this is not intended, the grant type should be explicit set.
-
setCodeVerifier
public TokenRequest.Builder setCodeVerifier(@Nullable String codeVerifier)
Specifies the code verifier for an authorization code exchange request.This must match the code verifier that was used to generate the challenge sent in the request that produced the authorization code.
-
setAdditionalParameters
@NonNull public TokenRequest.Builder setAdditionalParameters(@Nullable Map<String,String> additionalParameters)
Specifies an additional set of parameters to be sent as part of the request.
-
build
@NonNull public TokenRequest build()
Produces aTokenRequest
instance, if all necessary values have been provided.
-
-