Package com.nimbusds.oauth2.sdk
Class AuthorizationRequest
java.lang.Object
com.nimbusds.oauth2.sdk.AbstractRequest
com.nimbusds.oauth2.sdk.AuthorizationRequest
- Direct Known Subclasses:
AuthenticationRequest
Authorisation request. Used to authenticate an end-user and request the
end-user's consent to grant the client access to a protected resource.
Supports custom request parameters.
Extending classes may define additional request parameters as well as enforce tighter requirements on the base parameters.
Example HTTP request:
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
Related specifications:
- OAuth 2.0 (RFC 6749)
- OAuth 2.0 Multiple Response Type Encoding Practices 1.0
- OAuth 2.0 Form Post Response Mode 1.0
- Proof Key for Code Exchange by OAuth Public Clients (RFC 7636)
- OAuth 2.0 Rich Authorization Requests (RFC 9396)
- Resource Indicators for OAuth 2.0 (RFC 8707)
- OAuth 2.0 Incremental Authorization (draft-ietf-oauth-incremental-authz)
- The OAuth 2.0 Authorization Framework: JWT Secured Authorization Request (JAR) (RFC 9101)
- Financial-grade API: JWT Secured Authorization Response Mode for OAuth 2.0 (JARM)
- OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP) (RFC 9449)
- OpenID Connect Federation 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing authorisation requests. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAuthorizationRequest(URI endpoint, ResponseType rt, ClientID clientID) Creates a new minimal authorisation request.AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state) Creates a new authorisation request.AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<AuthorizationDetail> authorizationDetails, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, JWKThumbprintConfirmation dpopJKT, TrustChain trustChain, Map<String, List<String>> customParams) Creates a new authorisation request with extension and custom parameters.AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, JWKThumbprintConfirmation dpopJKT, TrustChain trustChain, Map<String, List<String>> customParams) Deprecated.AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, JWKThumbprintConfirmation dpopJKT, Map<String, List<String>> customParams) Deprecated.AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, Map<String, List<String>> customParams) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionReturns the Rich Authorisation Request (RAR) details.Returns the client identifier.Returns the code challenge for PKCE.Returns the code challenge method for PKCE.getCustomParameter(String name) Returns the specified custom parameter.Returns the additional custom parameters.Returns the DPoP JWK SHA-256 thumbprint.Returns the requested prompt.Returns the redirection URI.Returns the registered (standard) OAuth 2.0 authorisation request parameter names.com.nimbusds.jwt.JWTReturns the request object.Returns the request object URI.Returns the resource server URI.Returns the optional response mode.Returns the response type.getScope()Returns the scope.getState()Returns the state.Returns the OpenID Connect Federation 1.0 trust chain.Returns the implied response mode, determined by the optionalresponse_modeparameter, and if that isn't specified, by theresponse_type.booleanReturnstrueif incremental authorisation is requested.static AuthorizationRequestparse(HTTPRequest httpRequest) Parses an authorisation request from the specified HTTP GET or POST request.static AuthorizationRequestParses an authorisation request from the specified URI query string.static AuthorizationRequestParses an authorisation request from the specified URI.static AuthorizationRequestParses an authorisation request from the specified URI and query string.static AuthorizationRequestParses an authorisation request from the specified URI and query parameters.static AuthorizationRequestParses an authorisation request from the specified URI query parameters.booleanReturnstrueif this is a JWT secured authentication request.Returns the matching HTTP request.toHTTPRequest(HTTPRequest.Method method) Returns the matching HTTP request.com.nimbusds.jwt.JWTClaimsSetReturns the parameters for this authorisation request as a JSON Web Token (JWT) claims set.Returns the URI query parameters for this authorisation request.Returns the URI query string for this authorisation request.toURI()Returns the complete URI representation for this authorisation request, consisting of theauthorization endpoint URIwith thequery stringappended.Methods inherited from class com.nimbusds.oauth2.sdk.AbstractRequest
getEndpointURI
-
Field Details
-
prompt
The requested prompt (optional).
-
-
Constructor Details
-
AuthorizationRequest
Creates a new minimal authorisation request.- Parameters:
endpoint- The URI of the authorisation endpoint. May benullif the request is not going to be serialised.rt- The response type. Corresponds to theresponse_typeparameter. Must not benull.clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull.
-
AuthorizationRequest
public AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state) Creates a new authorisation request.- Parameters:
endpoint- The URI of the authorisation endpoint. May benullif the request is not going to be serialised.rt- The response type. Corresponds to theresponse_typeparameter. Must not benull.rm- The response mode. Corresponds to the optionalresponse_modeparameter. Use of this parameter is not recommended unless a non-default response mode is requested (e.g. form_post).clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull.redirectURI- The redirection URI. Corresponds to the optionalredirect_uriparameter.nullif not specified.scope- The request scope. Corresponds to the optionalscopeparameter.nullif not specified.state- The state. Corresponds to the recommendedstateparameter.nullif not specified.
-
AuthorizationRequest
@Deprecated public AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, Map<String, List<String>> customParams) Deprecated.Creates a new authorisation request with extension and custom parameters.- Parameters:
endpoint- The URI of the authorisation endpoint. May benullif the request is not going to be serialised.rt- The response type. Corresponds to theresponse_typeparameter. Must not benull, unless a request object or URI is specified.rm- The response mode. Corresponds to the optionalresponse_modeparameter. Use of this parameter is not recommended unless a non-default response mode is requested (e.g. form_post).clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull, unless a request object or URI is specified.redirectURI- The redirection URI. Corresponds to the optionalredirect_uriparameter.nullif not specified.scope- The request scope. Corresponds to the optionalscopeparameter.nullif not specified.state- The state. Corresponds to the recommendedstateparameter.nullif not specified.codeChallenge- The code challenge for PKCE,nullif not specified.codeChallengeMethod- The code challenge method for PKCE,nullif not specified.resources- The resource URI(s),nullif not specified.includeGrantedScopes-trueto request incremental authorisation.requestObject- The request object. Corresponds to the optionalrequestparameter. Must not be specified together with a request object URI.nullif not specified.requestURI- The request object URI. Corresponds to the optionalrequest_uriparameter. Must not be specified together with a request object.nullif not specified.prompt- The requested prompt. Corresponds to the optionalpromptparameter.customParams- Custom parameters, empty map ornullif none.
-
AuthorizationRequest
@Deprecated public AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, JWKThumbprintConfirmation dpopJKT, Map<String, List<String>> customParams) Deprecated.Creates a new authorisation request with extension and custom parameters.- Parameters:
endpoint- The URI of the authorisation endpoint. May benullif the request is not going to be serialised.rt- The response type. Corresponds to theresponse_typeparameter. Must not benull, unless a request object or URI is specified.rm- The response mode. Corresponds to the optionalresponse_modeparameter. Use of this parameter is not recommended unless a non-default response mode is requested (e.g. form_post).clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull, unless a request object or URI is specified.redirectURI- The redirection URI. Corresponds to the optionalredirect_uriparameter.nullif not specified.scope- The request scope. Corresponds to the optionalscopeparameter.nullif not specified.state- The state. Corresponds to the recommendedstateparameter.nullif not specified.codeChallenge- The code challenge for PKCE,nullif not specified.codeChallengeMethod- The code challenge method for PKCE,nullif not specified.resources- The resource URI(s),nullif not specified.includeGrantedScopes-trueto request incremental authorisation.requestObject- The request object. Corresponds to the optionalrequestparameter. Must not be specified together with a request object URI.nullif not specified.requestURI- The request object URI. Corresponds to the optionalrequest_uriparameter. Must not be specified together with a request object.nullif not specified.prompt- The requested prompt. Corresponds to the optionalpromptparameter.dpopJKT- The DPoP JWK SHA-256 thumbprint,nullif not specified.customParams- Custom parameters, empty map ornullif none.
-
AuthorizationRequest
@Deprecated public AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, JWKThumbprintConfirmation dpopJKT, TrustChain trustChain, Map<String, List<String>> customParams) Deprecated.Creates a new authorisation request with extension and custom parameters.- Parameters:
endpoint- The URI of the authorisation endpoint. May benullif the request is not going to be serialised.rt- The response type. Corresponds to theresponse_typeparameter. Must not benull, unless a request object or URI is specified.rm- The response mode. Corresponds to the optionalresponse_modeparameter. Use of this parameter is not recommended unless a non-default response mode is requested (e.g. form_post).clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull, unless a request object or URI is specified.redirectURI- The redirection URI. Corresponds to the optionalredirect_uriparameter.nullif not specified.scope- The request scope. Corresponds to the optionalscopeparameter.nullif not specified.state- The state. Corresponds to the recommendedstateparameter.nullif not specified.codeChallenge- The code challenge for PKCE,nullif not specified.codeChallengeMethod- The code challenge method for PKCE,nullif not specified.resources- The resource URI(s),nullif not specified.includeGrantedScopes-trueto request incremental authorisation.requestObject- The request object. Corresponds to the optionalrequestparameter. Must not be specified together with a request object URI.nullif not specified.requestURI- The request object URI. Corresponds to the optionalrequest_uriparameter. Must not be specified together with a request object.nullif not specified.prompt- The requested prompt. Corresponds to the optionalpromptparameter.dpopJKT- The DPoP JWK SHA-256 thumbprint,nullif not specified.trustChain- The OpenID Connect Federation 1.0 trust chain,nullif not specified.customParams- Custom parameters, empty map ornullif none.
-
AuthorizationRequest
public AuthorizationRequest(URI endpoint, ResponseType rt, ResponseMode rm, ClientID clientID, URI redirectURI, Scope scope, State state, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<AuthorizationDetail> authorizationDetails, List<URI> resources, boolean includeGrantedScopes, com.nimbusds.jwt.JWT requestObject, URI requestURI, Prompt prompt, JWKThumbprintConfirmation dpopJKT, TrustChain trustChain, Map<String, List<String>> customParams) Creates a new authorisation request with extension and custom parameters.- Parameters:
endpoint- The URI of the authorisation endpoint. May benullif the request is not going to be serialised.rt- The response type. Corresponds to theresponse_typeparameter. Must not benull, unless a request object or URI is specified.rm- The response mode. Corresponds to the optionalresponse_modeparameter. Use of this parameter is not recommended unless a non-default response mode is requested (e.g. form_post).clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull, unless a request object or URI is specified.redirectURI- The redirection URI. Corresponds to the optionalredirect_uriparameter.nullif not specified.scope- The request scope. Corresponds to the optionalscopeparameter.nullif not specified.state- The state. Corresponds to the recommendedstateparameter.nullif not specified.codeChallenge- The code challenge for PKCE,nullif not specified.codeChallengeMethod- The code challenge method for PKCE,nullif not specified.authorizationDetails- The Rich Authorisation Request (RAR) details,nullif not specified.resources- The resource URI(s),nullif not specified.includeGrantedScopes-trueto request incremental authorisation.requestObject- The request object. Corresponds to the optionalrequestparameter. Must not be specified together with a request object URI.nullif not specified.requestURI- The request object URI. Corresponds to the optionalrequest_uriparameter. Must not be specified together with a request object.nullif not specified.prompt- The requested prompt. Corresponds to the optionalpromptparameter.dpopJKT- The DPoP JWK SHA-256 thumbprint,nullif not specified.trustChain- The OpenID Connect Federation 1.0 trust chain,nullif not specified.customParams- Custom parameters, empty map ornullif none.
-
-
Method Details
-
getRegisteredParameterNames
Returns the registered (standard) OAuth 2.0 authorisation request parameter names.- Returns:
- The registered OAuth 2.0 authorisation request parameter names, as an unmodifiable set.
-
getResponseType
Returns the response type. Corresponds to theresponse_typeparameter.- Returns:
- The response type, may be
nullfor aJWT secured authorisation requestwith arequestorrequest_uriparameter.
-
getResponseMode
Returns the optional response mode. Corresponds to the optionalresponse_modeparameter.- Returns:
- The response mode,
nullif not specified.
-
impliedResponseMode
Returns the implied response mode, determined by the optionalresponse_modeparameter, and if that isn't specified, by theresponse_type.If the
jwtresponse mode shortcut from JARM is explicitly requested expands it toquery.jwtorfragment.jwtdepending on the response type (response_type).- Returns:
- The implied response mode.
-
getClientID
Returns the client identifier. Corresponds to theclient_idparameter.- Returns:
- The client identifier.
-
getRedirectionURI
Returns the redirection URI. Corresponds to the optionalredirection_uriparameter.- Returns:
- The redirection URI,
nullif not specified.
-
getScope
Returns the scope. Corresponds to the optionalscopeparameter.- Returns:
- The scope,
nullif not specified.
-
getState
Returns the state. Corresponds to the recommendedstateparameter.- Returns:
- The state,
nullif not specified.
-
getCodeChallenge
Returns the code challenge for PKCE.- Returns:
- The code challenge,
nullif not specified.
-
getCodeChallengeMethod
Returns the code challenge method for PKCE.- Returns:
- The code challenge method,
nullif not specified.
-
getAuthorizationDetails
Returns the Rich Authorisation Request (RAR) details.- Returns:
- The authorisation details,
nullif not specified.
-
getResources
Returns the resource server URI.- Returns:
- The resource URI(s),
nullif not specified.
-
includeGrantedScopes
Returnstrueif incremental authorisation is requested.- Returns:
trueif incremental authorisation is requested, elsefalse.
-
getRequestObject
Returns the request object. Corresponds to the optionalrequestparameter.- Returns:
- The request object,
nullif not specified.
-
getRequestURI
Returns the request object URI. Corresponds to the optionalrequest_uriparameter.- Returns:
- The request object URI,
nullif not specified.
-
specifiesRequestObject
Returnstrueif this is a JWT secured authentication request.- Returns:
trueif a request object via arequestorrequest_uriparameter is specified, elsefalse.
-
getPrompt
Returns the requested prompt. Corresponds to the optionalpromptparameter.- Returns:
- The requested prompt,
nullif not specified.
-
getDPoPJWKThumbprintConfirmation
Returns the DPoP JWK SHA-256 thumbprint.- Returns:
- The DPoP JWK SHA-256 thumbprint,
nullif not specified.
-
getTrustChain
Returns the OpenID Connect Federation 1.0 trust chain.- Returns:
- The trust chain,
nullif not specified.
-
getCustomParameters
Returns the additional custom parameters.- Returns:
- The additional custom parameters as a unmodifiable map, empty map if none.
-
getCustomParameter
Returns the specified custom parameter.- Parameters:
name- The parameter name. Must not benull.- Returns:
- The parameter value(s),
nullif not specified.
-
toParameters
Returns the URI query parameters for this authorisation request. Query parameters which are part of the authorisation endpoint are not included.Example parameters:
response_type = code client_id = s6BhdRkqt3 state = xyz redirect_uri = https://client.example.com/cb
- Returns:
- The parameters.
-
toJWTClaimsSet
Returns the parameters for this authorisation request as a JSON Web Token (JWT) claims set. Intended for creating a request object.- Returns:
- The parameters as JWT claim set.
-
toQueryString
Returns the URI query string for this authorisation request.Note that the '?' character preceding the query string in a URI is not included in the returned string.
Example URI query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
- Returns:
- The URI query string.
-
toURI
Returns the complete URI representation for this authorisation request, consisting of theauthorization endpoint URIwith thequery stringappended.Example URI:
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
- Returns:
- The URI representation.
-
toHTTPRequest
Returns the matching HTTP request.- Parameters:
method- The HTTP request method which can be GET or POST. Must not benull.- Returns:
- The HTTP request.
-
toHTTPRequest
Description copied from interface:RequestReturns the matching HTTP request.- Returns:
- The HTTP request.
-
parse
Parses an authorisation request from the specified URI query parameters.Example parameters:
response_type = code client_id = s6BhdRkqt3 state = xyz redirect_uri = https://client.example.com/cb
- Parameters:
params- The parameters. Must not benull.- Returns:
- The authorisation request.
- Throws:
ParseException- If the parameters couldn't be parsed to an authorisation request.
-
parse
public static AuthorizationRequest parse(URI uri, Map<String, List<String>> params) throws ParseExceptionParses an authorisation request from the specified URI and query parameters.Example parameters:
response_type = code client_id = s6BhdRkqt3 state = xyz redirect_uri = https://client.example.com/cb
- Parameters:
uri- The URI of the authorisation endpoint. May benullif thetoHTTPRequest()method will not be used.params- The parameters. Must not benull.- Returns:
- The authorisation request.
- Throws:
ParseException- If the parameters couldn't be parsed to an authorisation request.
-
parse
Parses an authorisation request from the specified URI query string.Example URI query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
- Parameters:
query- The URI query string. Must not benull.- Returns:
- The authorisation request.
- Throws:
ParseException- If the query string couldn't be parsed to an authorisation request.
-
parse
Parses an authorisation request from the specified URI and query string.Example URI query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
- Parameters:
uri- The URI of the authorisation endpoint. May benullif thetoHTTPRequest()method will not be used.query- The URI query string. Must not benull.- Returns:
- The authorisation request.
- Throws:
ParseException- If the query string couldn't be parsed to an authorisation request.
-
parse
Parses an authorisation request from the specified URI.Example URI:
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
- Parameters:
uri- The URI. Must not benull.- Returns:
- The authorisation request.
- Throws:
ParseException- If the URI couldn't be parsed to an authorisation request.
-
parse
Parses an authorisation request from the specified HTTP GET or POST request.Example HTTP request (GET):
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
- Parameters:
httpRequest- The HTTP request. Must not benull.- Returns:
- The authorisation request.
- Throws:
ParseException- If the HTTP request couldn't be parsed to an authorisation request.
-