java.lang.Object
dev.katsute.mal4j.AccessToken
Represents an access token.
- Since:
- 1.0.0
- Version:
- 2.7.0
- Author:
- Katsute
- See Also:
-
Constructor Summary
ConstructorDescriptionAccessToken
(String access_token) Creates an access token from a token.AccessToken
(String access_token, String refresh_token) Creates an access token from a token and refresh token.AccessToken
(String access_token, String refresh_token, long expiry_in_seconds) Creates an access token with expiry from a token and refresh token. -
Method Summary
Modifier and TypeMethodDescriptionfinal Date
Returns expiry date.final long
Returns expiry date as seconds since epoch.final String
Returns the refresh token or null.final long
Returns how long until the token expires in seconds.final String
getToken()
Returns token with token type.final boolean
Returns if the token used is expired.final String
toString()
-
Constructor Details
-
AccessToken
Creates an access token from a token.- Parameters:
access_token
- access token- Since:
- 2.7.0
- See Also:
-
AccessToken
Creates an access token from a token and refresh token.- Parameters:
access_token
- access tokenrefresh_token
- refresh token- Since:
- 2.7.0
- See Also:
-
AccessToken
Creates an access token with expiry from a token and refresh token.- Parameters:
access_token
- access tokenrefresh_token
- refresh tokenexpiry_in_seconds
- when the token expires as seconds since EPOCH- Since:
- 2.7.0
- See Also:
-
-
Method Details
-
getToken
Returns token with token type. Ex: 'Bearer oauth2token'- Returns:
- token
- Since:
- 1.0.0
-
getRefreshToken
Returns the refresh token or null.- Returns:
- refresh token
- Throws:
NullPointerException
- if the refresh token is missing- Since:
- 1.0.0
-
getExpiry
Returns expiry date.- Returns:
- expiry date
- Throws:
NullPointerException
- if the expiry date is missing- Since:
- 1.0.0
- See Also:
-
getExpiryEpochSeconds
public final long getExpiryEpochSeconds()Returns expiry date as seconds since epoch.- Returns:
- expiry date
- Throws:
NullPointerException
- if the expiry date is missing- Since:
- 2.7.0
- See Also:
-
getTimeUntilExpires
public final long getTimeUntilExpires()Returns how long until the token expires in seconds.- Returns:
- time until expiry
- Throws:
NullPointerException
- if the expiry date is missing- Since:
- 1.0.0
- See Also:
-
isExpired
public final boolean isExpired()Returns if the token used is expired.- Returns:
- if the token used is expired
- Throws:
NullPointerException
- if the expiry date is missing- Since:
- 1.0.0
- See Also:
-
toString
-