Package net.amcintosh.freshbooks.models
Class AuthorizationToken
java.lang.Object
net.amcintosh.freshbooks.models.AuthorizationToken
Authorization data including the OAuth bearer token, expiry, and refresh token.
-
Constructor Summary
ConstructorDescriptionCreate empty authorization data.AuthorizationToken
(String accessToken) Create authorization data from a pre-existing, valid, bearer token.AuthorizationToken
(String accessToken, String refreshToken) Create authorization data from pre-existing, valid, bearer and refresh tokens. -
Method Summary
Modifier and TypeMethodDescriptionGet the authorized bearer token from the OAuth2 token response.Time the bearer token was created.Time the bearer token expires at.long
Number of seconds since creation that the token will expire at.Get the authorized refresh token from the OAuth2 token response.Get the scopes that the token is authorized for.void
setAccessToken
(String accessToken) Set the bearer token for use in the client.void
setRefreshToken
(String refreshToken) Set the refresh token for use in the client.
-
Constructor Details
-
AuthorizationToken
public AuthorizationToken()Create empty authorization data. -
AuthorizationToken
Create authorization data from a pre-existing, valid, bearer token.- Parameters:
accessToken
-
-
AuthorizationToken
Create authorization data from pre-existing, valid, bearer and refresh tokens.- Parameters:
accessToken
-refreshToken
-
-
-
Method Details
-
getAccessToken
Get the authorized bearer token from the OAuth2 token response.- Returns:
-
setAccessToken
Set the bearer token for use in the client.- Parameters:
accessToken
-
-
getRefreshToken
Get the authorized refresh token from the OAuth2 token response.- Returns:
-
setRefreshToken
Set the refresh token for use in the client. This will allow the client to call the token refresh and get a new bearer token if expired.- Parameters:
refreshToken
-
-
getCreatedAt
Time the bearer token was created.- Returns:
- UTC ZonedDateTime
-
getExpiresAt
Time the bearer token expires at.- Returns:
- UTC ZonedDateTime
-
getExpiresIn
public long getExpiresIn()Number of seconds since creation that the token will expire at.
Please notegetExpiresAt()
which calculates the expiry time from this and createdAt.- Returns:
- Seconds
-
getScopes
Get the scopes that the token is authorized for.- Returns:
- List of scope strings.
-