Class OAuth20Token
java.lang.Object
org.openstreetmap.josm.data.oauth.OAuth20Token
- All Implemented Interfaces:
IOAuthToken
Token holder for OAuth 2.0
- Since:
- 18650
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate final Stringprivate static final Stringprivate final Instantprivate static final Stringprivate final intprivate final IOAuthParametersprivate static final Stringprivate final Stringprivate static final Stringprivate final String[]private static final Stringprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionOAuth20Token(IOAuthParameters oauthParameters, Reader bufferedReader) OAuth20Token(IOAuthParameters oauthParameters, String json) Create a new OAuth token -
Method Summary
Modifier and TypeMethodDescriptionstatic OAuth20TokenfromAccessToken(IOAuthParameters oauthParameters, String accessToken) Create a bearer token from the access token alone, such as a token issued outside JOSM and pasted by the user.Get the OAuth 2.0 bearer tokenGet the auth type of this tokenGet the OAuth parameters(package private) OAuth20Tokenrefresh()Refresh the OAuth 2.0 token(package private) booleanCheck if the token should be refreshedvoidsign(HttpClient client) Sign a clientGet the preferences string of this auth token.
-
Field Details
-
ACCESS_TOKEN
- See Also:
-
CREATED_AT
- See Also:
-
EXPIRES_IN
- See Also:
-
REFRESH_TOKEN
- See Also:
-
SCOPE
- See Also:
-
TOKEN_TYPE
- See Also:
-
accessToken
-
tokenType
-
expiresIn
-
refreshToken
-
scopes
-
createdAt
-
oauthParameters
-
-
Constructor Details
-
OAuth20Token
Create a new OAuth token- Parameters:
oauthParameters- The parameters for the OAuth tokenjson- The stored JSON for the token- Throws:
OAuth20Exception- If the JSON creates an invalid token
-
OAuth20Token
OAuth20Token(IOAuthParameters oauthParameters, Reader bufferedReader) throws OAuth20Exception - Throws:
OAuth20Exception
-
-
Method Details
-
fromAccessToken
Create a bearer token from the access token alone, such as a token issued outside JOSM and pasted by the user. It has no refresh token, and works with nothing else: the parameters only need the API URL the token is for.- Parameters:
oauthParameters- The parameters for the OAuth tokenaccessToken- The access token- Returns:
- The bearer token
- Since:
- 19707
-
sign
Description copied from interface:IOAuthTokenSign a client- Specified by:
signin interfaceIOAuthToken- Parameters:
client- The client to sign- Throws:
OAuthException- if the OAuth token type is unknown (AKA we don't know how to handle it)
-
getBearerToken
Get the OAuth 2.0 bearer token- Returns:
- The bearer token. May return
nullif the token type is not a bearer type.
-
toPreferencesString
Description copied from interface:IOAuthTokenGet the preferences string of this auth token. This should match the expected return body from the authentication server. For OAuth, this is typically JSON.- Specified by:
toPreferencesStringin interfaceIOAuthToken- Returns:
- The preferences string
-
getOAuthType
Description copied from interface:IOAuthTokenGet the auth type of this token- Specified by:
getOAuthTypein interfaceIOAuthToken- Returns:
- The auth type
-
getParameters
Description copied from interface:IOAuthTokenGet the OAuth parameters- Specified by:
getParametersin interfaceIOAuthToken- Returns:
- The OAuth parameters
-
shouldRefresh
boolean shouldRefresh()Check if the token should be refreshed- Returns:
trueif the token should be refreshed
-
refresh
Refresh the OAuth 2.0 token- Returns:
- The new token to use
-