Package com.nimbusds.oauth2.sdk.token
Class Tokens
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.token.Tokens
-
- Direct Known Subclasses:
OIDCTokens
@Immutable public class Tokens extends Object
Access and optional refresh token.
-
-
Constructor Summary
Constructors Constructor Description Tokens(AccessToken accessToken, RefreshToken refreshToken)Creates a new tokens instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessTokengetAccessToken()Returns the access token.BearerAccessTokengetBearerAccessToken()Returns the access token as type bearer.Set<String>getParameterNames()Returns the token parameter names for the included tokens.RefreshTokengetRefreshToken()Returns the optional refresh token.static Tokensparse(net.minidev.json.JSONObject jsonObject)Parses an access and optional refresh token from the specified JSON object.net.minidev.json.JSONObjecttoJSONObject()Returns the JSON object representation of this token pair.OIDCTokenstoOIDCTokens()Casts to OpenID Connect tokens.StringtoString()
-
-
-
Constructor Detail
-
Tokens
public Tokens(AccessToken accessToken, RefreshToken refreshToken)
Creates a new tokens instance.- Parameters:
accessToken- The access token. Must not benull.refreshToken- The refresh token. If nonenull.
-
-
Method Detail
-
getAccessToken
public AccessToken getAccessToken()
Returns the access token.- Returns:
- The access token.
-
getBearerAccessToken
public BearerAccessToken getBearerAccessToken()
Returns the access token as type bearer.- Returns:
- The bearer access token,
nullif the type is different.
-
getRefreshToken
public RefreshToken getRefreshToken()
Returns the optional refresh token.- Returns:
- The refresh token,
nullif none.
-
getParameterNames
public Set<String> getParameterNames()
Returns the token parameter names for the included tokens.- Returns:
- The token parameter names.
-
toJSONObject
public net.minidev.json.JSONObject 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
public OIDCTokens toOIDCTokens()
Casts to OpenID Connect tokens.- Returns:
- The OpenID Connect tokens (including an ID token).
-
parse
public static Tokens parse(net.minidev.json.JSONObject jsonObject) throws ParseException
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.
-
-