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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| discord_oauth2_py-1.2.2.tar.gz | 7.6 kB | Without provenance | Details for discord_oauth2_py-1.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| discord_oauth2_py-1.2.2-py3-none-any.whl | Python 3 | none | any | Details for discord_oauth2_py-1.2.2-py3-none-any.whl |
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
|
Security for discord-oauth2.py 1.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.