Package discord4j.oauth2.object
Class AccessToken
java.lang.Object
discord4j.oauth2.object.AccessToken
Access token details for a single OAuth2 authorized client.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the OAuth2 access token.discord4j.discordjson.json.AccessTokenDatagetData()Return the raw data object for this tokenOptional<discord4j.discordjson.json.GuildUpdateData>getGuild()Return information about the guild to which your bot was added, available when authorizing a user with aScope.BOTscope.Return the OAuth2 refresh token, if available.Return the OAuth2 scopes in this access token.Optional<discord4j.discordjson.json.WebhookData>Return webhook information if this client was authorized using aScope.WEBHOOK_INCOMINGscope.booleanReturn whether this token has expired according to the token expires_in field and this object creation date.
-
Constructor Details
-
AccessToken
public AccessToken(discord4j.discordjson.json.AccessTokenData data)
-
-
Method Details
-
getData
public discord4j.discordjson.json.AccessTokenData getData()Return the raw data object for this token- Returns:
- a data object with the token details
-
getAccessToken
Return the OAuth2 access token.- Returns:
- the OAuth2 access token
-
hasExpired
public boolean hasExpired()Return whether this token has expired according to the token expires_in field and this object creation date.- Returns:
trueif this token has expired and a refresh token flow must be used,falseotherwise
-
getRefreshToken
Return the OAuth2 refresh token, if available.- Returns:
- an Optional with the OAuth2 refresh token or an empty optional if not present
-
getScopes
Return the OAuth2 scopes in this access token.- Returns:
- an EnumSet of the scopes in the access token
-
getGuild
Return information about the guild to which your bot was added, available when authorizing a user with aScope.BOTscope.- Returns:
- a data object with the guild joined by your bot
- See Also:
-
getWebhook
Return webhook information if this client was authorized using aScope.WEBHOOK_INCOMINGscope. By fetchingWebhookData.token()andWebhookData.id()you can send messages with the webhook.- Returns:
- webhook details tied to this access token, if present
-