Skip to content

Only select scopes work with client credentials flow #2456

@Fyko

Description

@Fyko

Description
When following the client credential flow, only select scopes are permitted for use (identify and applications.commands.update). If another scope -- such as email is specified, an error is thrown. Is this expected behavior?

The documentation states:

You can specify scopes with the scope parameter, which is a list of OAuth2 scopes separated by spaces

Steps to Reproduce

  1. Copy the following code snippet
var id = "";
var secret = "";

var headers = new Headers();
headers.append("Content-Type", "application/x-www-form-urlencoded");

var body = new URLSearchParams();
body.append("grant_type", "client_credentials");
body.append("scope", "identify email");
body.append("client_id", id);
body.append("client_secret", secret);

var requestOptions = {
  method: 'POST',
  headers,
  body,
  redirect: 'follow'
};

fetch("https://discord.com/api/oauth2/token", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
  1. Edit the id and secret values to a client id and client secret respectively
  2. Run the code sample in the Developer Tools console
  3. Observe

Expected Behavior
A (bearer) token is returned with access to the authorized user's email.

Current Behavior
The following error is thrown:

{
   "error":"invalid_scope",
   "error_description":"The requested scope is invalid, unknown, or malformed."
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions