Enum Class Scope

java.lang.Object
java.lang.Enum<Scope>
com.jagrosh.jdautilities.oauth2.Scope
All Implemented Interfaces:
Serializable, Comparable<Scope>, Constable

public enum Scope extends Enum<Scope>
Constants used to specify the scope of OAuth2 sessions.

All OAuth2 sessions can act within' their available scope upon creation, and as such, these are specified in when the session's are created.

Author:
John Grosh ([email protected])
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    For oauth2 bots, this puts the bot in the user's selected guild by default
    Allows /users/@me/connections to return linked third-party accounts
    Enables /users/@me to return an email
    Allows your app to join users to a group dm
    Allows /users/@me/guilds to return basic information about all of a user's guilds
    Allows /invites/{invite.id} to be used for joining users to a guild
    Allows /users/@me without email
    For local rpc server api access, this allows you to read messages from all client channels (otherwise restricted to channels/guilds your app creates)
    For local rpc server access, this allows you to control a user's local Discord client
    For local rpc server api access, this allows you to access the API as the local user
    For local rpc server api access, this allows you to receive notifications pushed out to the user
    Unknown scope
    This generates a webhook that is returned in the oauth token response for authorization code grants
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(Scope[] scopes, Scope scope)
     
    static Scope
    from(String scope)
    Gets a scope based on the specified text key.
    The text key associated with this scope.
    static String
    join(boolean bySpace, Scope... scopes)
    Joins the specified scopes properly as they should be represented as part of an authorization URL.
    static String
    join(Scope... scopes)
    Joins the specified scopes properly as they should be represented as part of an authorization URL.
    static Scope
    Returns the enum constant of this class with the specified name.
    static Scope[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • BOT

      public static final Scope BOT
      For oauth2 bots, this puts the bot in the user's selected guild by default
    • CONNECTIONS

      public static final Scope CONNECTIONS
      Allows /users/@me/connections to return linked third-party accounts
    • EMAIL

      public static final Scope EMAIL
      Enables /users/@me to return an email
    • IDENTIFY

      public static final Scope IDENTIFY
      Allows /users/@me without email
    • GUILDS

      public static final Scope GUILDS
      Allows /users/@me/guilds to return basic information about all of a user's guilds
    • GUILDS_JOIN

      public static final Scope GUILDS_JOIN
      Allows /invites/{invite.id} to be used for joining users to a guild
    • GDM_JOIN

      public static final Scope GDM_JOIN
      Allows your app to join users to a group dm
    • MESSAGES_READ

      public static final Scope MESSAGES_READ
      For local rpc server api access, this allows you to read messages from all client channels (otherwise restricted to channels/guilds your app creates)
    • RPC

      public static final Scope RPC
      For local rpc server access, this allows you to control a user's local Discord client
    • RPC_API

      public static final Scope RPC_API
      For local rpc server api access, this allows you to access the API as the local user
    • RPC_NOTIFICATIONS_READ

      public static final Scope RPC_NOTIFICATIONS_READ
      For local rpc server api access, this allows you to receive notifications pushed out to the user
    • WEBHOOK_INCOMING

      public static final Scope WEBHOOK_INCOMING
      This generates a webhook that is returned in the oauth token response for authorization code grants
    • UNKNOWN

      public static final Scope UNKNOWN
      Unknown scope
  • Method Details

    • values

      public static Scope[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Scope valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getText

      public String getText()
      The text key associated with this scope.
      Returns:
      The text key associated with this scope.
    • contains

      public static boolean contains(Scope[] scopes, Scope scope)
    • join

      public static String join(Scope... scopes)
      Joins the specified scopes properly as they should be represented as part of an authorization URL.
      Parameters:
      scopes - The scopes to join.
      Returns:
      A String representing how the scopes should be represented as part of an authorization URL.
    • join

      public static String join(boolean bySpace, Scope... scopes)
      Joins the specified scopes properly as they should be represented as part of an authorization URL.
      Parameters:
      bySpace - If the scopes should be joined by " " or "%20" (default: "%20")
      scopes - The scopes to join.
      Returns:
      A String representing how the scopes should be represented as part of an authorization URL.
    • from

      public static Scope from(String scope)
      Gets a scope based on the specified text key.
      Parameters:
      scope - A text key to get a scope by.
      Returns:
      The scope matching the provided text key (UNKNOWN by default)