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

Disord Auth #102

Open
lenisko opened this issue Mar 12, 2023 · 0 comments
Open

Disord Auth #102

lenisko opened this issue Mar 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@lenisko
Copy link
Collaborator

lenisko commented Mar 12, 2023

For both server & client I guess.

You could implement simple OAuth and use this endpoint to pull user roles. No need to create & handle a bot. But not denying that :)

Example py implementation to fetch user roles:

# oauth session creation flags.
# configurable `prompt` would be great as well (this allows to skip Discord prompt if user autorized once.
discord.create_session(prompt=config["prompt"], scope=['identify', 'guilds', 'guilds.members.read'])

# Fetch user roles
def user_roles(access_token):
    headers = {'Authorization': f'Bearer {access_token}'}
    req = requests.get(f'https://discord.com/api/users/@me/guilds/{guild_id}/member', headers=headers)
    roles = req.json()
    output = []

    for role_id in roles.get("roles", []):
        output.append(role_id)

    return roles
@lenisko lenisko added the enhancement New feature or request label Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant