Skip to content

DiscordApplication.GenerateBotOAuth does not account for all OAuth scopes #1292

Description

@SakuraIsayeki

Summary

Using the DiscordApplication.GenerateBotOAuth() method does not allow selecting all scopes to generate an OAuth URI.
It currently only supports the bot scope, and doesn't support redirect URIs.

Details

Starting from an ideal result of
https://discord.com/api/oauth2/authorize?client_id=583412458560159776&permissions=8&scope=bot%20applications.commands
This link has scopes bot and applications.commands and permission 0x8 (Administrator) specified.

(Generated from Discord's OAuth URL Generator tool, using the following settings)
image

However, the current method only allows specifying a DSharpPlus.Permissions argument, inferring that the OAuth link will only use the bot scope.

Ideally, we should be able to specify further parameters, like OAuth scopes, and a redirect link, used by other scopes (only bot and applications.commands don't make use of a redirect).

An ideal implementation would be an overload, or extending the current method, as such:

public string GenerateBotOAuth(
    Permissions permissions = Permissions.None, 
    OAuthScopes scopes = OAuthScopes.Bot, 
    string RedirectUri = null) 
{ /* Implementation */ }

// TODO: Add OAuthScopes enum.

Instead of the current method, found here (source) :

public string GenerateBotOAuth(Permissions permissions = Permissions.None) { /* Implementation */ }

Let it also be known that the current method spars absolutely no documentation whatsoever, so we might want to brush up on that too ^^

Steps to reproduce

N/A

Notes

If maintainers have their hands full, I'd be happy to Fork & PR relevant changes, as well as add documentation to the method, given my first-hand interest in this issue.

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions