Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid_scope error from Discord after using auth URL provided by generateAuthUrl. #33

Closed
roncli opened this issue Oct 11, 2020 · 1 comment
Assignees
Labels
good first issue Good for newcomers

Comments

@roncli
Copy link

roncli commented Oct 11, 2020

Describe the error
generateAuthUrl generates what appears to be a valid URL, but upon hitting "Authorize" on the discord.com page, I get a URL back with the querystring ?error=invalid_scope&error_description=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed.&state=<my state>.

NodeJS version
v12.18.4 (from node:lts-alpine on Docker Hub)

Relevant code

        return oauth.generateAuthUrl({
            scope: process.env.DISCORD_USERSCOPES,
            state
        });

process.env.DISCORD_USERSCOPES is "identify connections guilds relationships.read".

state is crypto.randomBytes(16).toString("hex").

The URL this generates is https://discord.com/oauth2/authorize?client_id=<my client id>&redirect_uri=https%3A%2F%2F<my redirect uri>&response_type=code&scope=identify%20connections%20guilds%20relationships.read&state=<my state>.

The page on Discord appears to understand this:
image

However, on clicking Authorize, it returns me to this URL: https://<my redirect uri>?error=invalid_scope&error_description=The+requested+scope+is+invalid%2C+unknown%2C+or+malformed.&state=<my state> The redirect uri and the state both match the generated URL.

The scopes are valid and are listed under https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes. Any idea what I am doing wrong here?

@roncli
Copy link
Author

roncli commented Oct 11, 2020

Disregard. The issue is relationships.read is apparently behind a whitelist that Discord controls, and apparently isn't open for applications. It would have been nice if the documentation I was using for this had mentioned there was this whitelist! Sorry for the trouble, but leaving this comment here in case anyone else gets stung by this. :)

@roncli roncli closed this as completed Oct 11, 2020
@reboxer reboxer added the good first issue Good for newcomers label Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants