Package com.nimbusds.oauth2.sdk
Class AuthorizationCodeGrant
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.AuthorizationGrant
-
- com.nimbusds.oauth2.sdk.AuthorizationCodeGrant
-
@Immutable public class AuthorizationCodeGrant extends AuthorizationGrant
Authorisation code grant. Used in access token requests with an authorisation code.Related specifications:
- OAuth 2.0 (RFC 6749), section 4.1.3.
- Proof Key for Code Exchange by OAuth Public Clients (RFC 7636).
-
-
Field Summary
Fields Modifier and Type Field Description static GrantType
GRANT_TYPE
The grant type.
-
Constructor Summary
Constructors Constructor Description AuthorizationCodeGrant(AuthorizationCode code, URI redirectURI)
Creates a new authorisation code grant.AuthorizationCodeGrant(AuthorizationCode code, URI redirectURI, CodeVerifier codeVerifier)
Creates a new authorisation code grant.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
AuthorizationCode
getAuthorizationCode()
Gets the authorisation code.CodeVerifier
getCodeVerifier()
Gets the authorisation code verifier for PKCE.URI
getRedirectionURI()
Gets the redirection URI of the original authorisation request.int
hashCode()
static AuthorizationCodeGrant
parse(Map<String,List<String>> params)
Parses an authorisation code grant from the specified request body parameters.Map<String,List<String>>
toParameters()
Returns the request body parameters for the authorisation grant.-
Methods inherited from class com.nimbusds.oauth2.sdk.AuthorizationGrant
getType
-
-
-
-
Field Detail
-
GRANT_TYPE
public static final GrantType GRANT_TYPE
The grant type.
-
-
Constructor Detail
-
AuthorizationCodeGrant
public AuthorizationCodeGrant(AuthorizationCode code, URI redirectURI)
Creates a new authorisation code grant.- Parameters:
code
- The authorisation code. Must not benull
.redirectURI
- The redirection URI of the original authorisation request. Required if the {redirect_uri} parameter was included in the authorisation request, elsenull
.
-
AuthorizationCodeGrant
public AuthorizationCodeGrant(AuthorizationCode code, URI redirectURI, CodeVerifier codeVerifier)
Creates a new authorisation code grant.- Parameters:
code
- The authorisation code. Must not benull
.redirectURI
- The redirection URI of the original authorisation request. Required if the {redirect_uri} parameter was included in the authorisation request, elsenull
.codeVerifier
- The authorisation code verifier for PKCE,null
if not specified.
-
-
Method Detail
-
getAuthorizationCode
public AuthorizationCode getAuthorizationCode()
Gets the authorisation code.- Returns:
- The authorisation code.
-
getRedirectionURI
public URI getRedirectionURI()
Gets the redirection URI of the original authorisation request.- Returns:
- The redirection URI,
null
if theredirect_uri
parameter was not included in the original authorisation request.
-
getCodeVerifier
public CodeVerifier getCodeVerifier()
Gets the authorisation code verifier for PKCE.- Returns:
- The authorisation code verifier,
null
if not specified.
-
toParameters
public Map<String,List<String>> toParameters()
Description copied from class:AuthorizationGrant
Returns the request body parameters for the authorisation grant.- Specified by:
toParameters
in classAuthorizationGrant
- Returns:
- The parameters.
-
parse
public static AuthorizationCodeGrant parse(Map<String,List<String>> params) throws ParseException
Parses an authorisation code grant from the specified request body parameters.Example:
grant_type=authorization_code code=SplxlOBeZQQYbYS6WxSbIA redirect_uri=https://Fclient.example.com/cb
- Parameters:
params
- The parameters.- Returns:
- The authorisation code grant.
- Throws:
ParseException
- If parsing failed.
-
-