Package com.nimbusds.oauth2.sdk.token
Class Tokens
java.lang.Object
com.nimbusds.oauth2.sdk.token.Tokens
- Direct Known Subclasses:
OIDCTokens
Access and optional refresh token.
-
Constructor Summary
ConstructorsConstructorDescriptionTokens
(AccessToken accessToken, RefreshToken refreshToken) Creates a new tokens instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the access token.Returns the access token as type bearer.Returns the access token as type DPoP.Returns the optional modifiable token metadata.Returns the token parameter names for the included tokens.Returns the optional refresh token.static Tokens
parse
(net.minidev.json.JSONObject jsonObject) Parses an access and optional refresh token from the specified JSON object.net.minidev.json.JSONObject
Returns the JSON object representation of this token pair.Casts to OpenID Connect tokens.toString()
-
Constructor Details
-
Tokens
Creates a new tokens instance.- Parameters:
accessToken
- The access token. Must not benull
.refreshToken
- The refresh token. If nonenull
.
-
-
Method Details
-
getAccessToken
Returns the access token.- Returns:
- The access token.
-
getBearerAccessToken
Returns the access token as type bearer.- Returns:
- The bearer access token,
null
if the type is different.
-
getDPoPAccessToken
Returns the access token as type DPoP.- Returns:
- The DPoP access token,
null
if the type is different.
-
getRefreshToken
Returns the optional refresh token.- Returns:
- The refresh token,
null
if none.
-
getParameterNames
Returns the token parameter names for the included tokens.- Returns:
- The token parameter names.
-
getMetadata
Returns the optional modifiable token metadata. Intended for server environments.- Returns:
- The token metadata.
-
toJSONObject
Returns the JSON object representation of this token pair.Example JSON object:
{ "access_token" : "dZdt8BlltORMTz5U", "refresh_token" : "E87zjAoeNXaSoF1U" }
- Returns:
- The JSON object representation.
-
toOIDCTokens
Casts to OpenID Connect tokens.- Returns:
- The OpenID Connect tokens (including an ID token).
-
toString
-
parse
Parses an access and optional refresh token from the specified JSON object.- Parameters:
jsonObject
- The JSON object to parse. Must not benull
.- Returns:
- The tokens.
- Throws:
ParseException
- If the JSON object couldn't be parsed to a tokens instance.
-