Use Discord's OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation.
Project description
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
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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file discord-oauth2.py-1.2.1.tar.gz
.
File metadata
- Download URL: discord-oauth2.py-1.2.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3703fdbcec5a526a8160e8f39eee79163eea29a7aab2c92df8c2146daf542a35 |
|
MD5 | 57be2b9e9010d02036085e7725c75ecf |
|
BLAKE2b-256 | 503aadc2ddbf59fa5929147d9a52565f461b31248d71f7618b516d74942de7af |
File details
Details for the file discord_oauth2.py-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: discord_oauth2.py-1.2.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d89fe690e9c9d81e127be4492239f7e38a2e8139afd69a31e84afdccd30f9b3 |
|
MD5 | a53d3adec8d6b724fdf3dd94d4df2c1a |
|
BLAKE2b-256 | 0058dfd0e31b253e4bd7180376018ce2410e221a644568d13550d24fae91817f |