Package discord4j.oauth2.object
Class AccessToken
- java.lang.Object
-
- discord4j.oauth2.object.AccessToken
-
public class AccessToken extends Object
Access token details for a single OAuth2 authorized client.
-
-
Constructor Summary
Constructors Constructor Description AccessToken(discord4j.discordjson.json.AccessTokenData data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAccessToken()
Return the OAuth2 access token.discord4j.discordjson.json.AccessTokenData
getData()
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.BOT
scope.Optional<String>
getRefreshToken()
Return the OAuth2 refresh token, if available.EnumSet<Scope>
getScopes()
Return the OAuth2 scopes in this access token.Optional<discord4j.discordjson.json.WebhookData>
getWebhook()
Return webhook information if this client was authorized using aScope.WEBHOOK_INCOMING
scope.boolean
hasExpired()
Return whether this token has expired according to the token expires_in field and this object creation date.
-
-
-
Method Detail
-
getData
public discord4j.discordjson.json.AccessTokenData getData()
Return the raw data object for this token- Returns:
- a data object with the token details
-
getAccessToken
public String 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:
true
if this token has expired and a refresh token flow must be used,false
otherwise
-
getRefreshToken
public Optional<String> getRefreshToken()
Return the OAuth2 refresh token, if available.- Returns:
- an Optional with the OAuth2 refresh token or an empty optional if not present
-
getScopes
public EnumSet<Scope> getScopes()
Return the OAuth2 scopes in this access token.- Returns:
- an EnumSet of the scopes in the access token
-
getGuild
public Optional<discord4j.discordjson.json.GuildUpdateData> getGuild()
Return information about the guild to which your bot was added, available when authorizing a user with aScope.BOT
scope.- Returns:
- a data object with the guild joined by your bot
- See Also:
- Discord
-
getWebhook
public Optional<discord4j.discordjson.json.WebhookData> getWebhook()
Return webhook information if this client was authorized using aScope.WEBHOOK_INCOMING
scope. By fetchingWebhookData.token()
andWebhookData.id()
you can send messages with the webhook.- Returns:
- webhook details tied to this access token, if present
-
-