Skip to main content

DiscordOAuth2.py

Use Discord's OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation.

Useful Links

Discord Server: https://discord.gg/DJ9xbbZAP5

Documentation is coming soon, don't worry.

Quickstart

Installing

I've finally published the library to PyPi! So now you can use pip.

pip install discord-oauth2.py

Example With Flask

Don't forget to replace all the client information with your application's own information. You can leave bot token empty if your not adding members to guilds.

import discordoauth2
from flask import Flask, request, redirect

client = discordoauth2.Client(849930878276993044, secret="very-secret-code",
redirect="https://findingfakeurlsisprettyhard.tv/oauth2", bot_token="bot-token-only-required-for-guild-joining-or-updating-linked-roles-metadata")
app = Flask(__name__)

client.update_linked_roles_metadata([
    {
        "type": 2,
        "key": "level",
        "name": "Level",
        "description": "The level the user is on"
    },
    {
        "type": 7,
        "key": "supporter",
        "name": "Supporter",
        "description": "Spent money to help the game"
    }
])

@app.route('/')
def main():
  return redirect(client.generate_uri(scope=["identify", "connections", "guilds", "role_connections.write"]))

@app.route("/oauth2")
def oauth2():
    code = request.args.get("code")

    access = client.exchange_code(code)

    access.update_metadata("Platform Name", "Username",  level=69, supporter=True)

    identify = access.fetch_identify()
    connections = access.fetch_connections()
    guilds = access.fetch_guilds()

    return f"""{identify}<br><br>{connections}<br><br>{guilds}"""

app.run("0.0.0.0", 8080)

Async usage

Asynchronous usage is also supported, you can use the async version of the library by importing discordoauth2.AsyncClient instead of discordoauth2.Client. The methods are the same, but they’re coroutines.

Metadata

Release files for discord-oauth2.py 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discord-oauth2.py 1.2.2
File Size Uploaded
discord_oauth2_py-1.2.2.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for discord-oauth2.py 1.2.2
File Interpreter ABI Platform
discord_oauth2_py-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / discord_oauth2_py-1.2.2.tar.gz

Download URL discord_oauth2_py-1.2.2.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bb17f3483abf9c90dfa3b68a607c6e05ed2f42a2d5bb1aa87e188a36d6b07e9f
BLAKE2b-256 checksum
How to use checksums
651c64df8019cd58adc5045700f6935afe8e2f466bee3d64e088bc66ba58ff1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / discord_oauth2_py-1.2.2-py3-none-any.whl

Download URL discord_oauth2_py-1.2.2-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b04892c9199be537e846d819ee3a2795d6676e5734003a7868ae89fdd967218
BLAKE2b-256 checksum
How to use checksums
7ad80e242634e4eba80a073a0e1fc60470e38b9b96f9d784def218d13d0abb43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page