Skip to main content

Discord Oauth2 Client for Quart and a easy to use API Wrapper for dprofiles.xyz

Project description

Install the packages

!!! INFO !!!

Visit our documentation for more information/explanation.

pip install dprofiles.

Head over to the Discord developer site to get your Bots Token, Client ID and secret (if you are using the Oauth2 Client). Make sure to also set a redirect URL for your bot.

Example Application of the Client for dprofiles

import dprofiles

client = dprofiles.Client("<your token>")

client.get(670663150365835285) # returns all user information

client.get(670663150365835285, "bio") # returns the information for "bio"

client.get(670663150365835285, "bio", save=True) # saves returned content into {user-ID}.json

client.check_vote(670663150365835285, [second-ID]) # True if user a has voted for user b

client.has_voted(70663150365835285) # True if voted in last 6/12h

Example Application of the Oauth2 Client

from dprofiles.ext import DiscordOauth2Client
from quart import Quart, redirect, render_template_string, request, url_for

app = Quart(__name__)
app.secret_key = b"some random bytes for the secret quart key"
app.config['DISCORD_CLIENT_ID'] = ""
app.config['DISCORD_CLIENT_SECRET'] = ""
app.config['SCOPES'] = ['identify']
app.config['DISCORD_REDIRECT_URI'] = 'http://127.0.0.1:5000/callback'
app.config['DISCORD_BOT_TOKEN'] = ""

client = DiscordOauth2Client(app)


@app.route('/')
@client.is_logged_in
async def index():
    user = await client.fetch_user()
    return f"Hello, {user.name}!"


@app.route('/login/', methods=['GET'])
async def login():
    return await client.create_session()


@app.route('/callback')
async def callback():
    await client.callback()
    return redirect(url_for('index')) #redirects to "/"


if __name__ == '__main__':
    app.run()

Scopes

  • identify returns /users/@me without email.
  • email returns /users/@me with an email.
  • connections returns linked accounts (Youtube, Spotify...)
  • guilds returns the users guilds
  • guilds.join can be used to join a guild for a user

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

dprofiles-0.0.2.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file dprofiles-0.0.2.tar.gz.

File metadata

  • Download URL: dprofiles-0.0.2.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for dprofiles-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8d95540758fda2687e18a8cd2bd95befe7ab8b78cde3841d0724afe2cb842cc3
MD5 a7921fe9a84ef66e2342e68e438ee8dc
BLAKE2b-256 9b016f38642f386bd353f65a67c8ac8fe55053016d30ef1878791d70020ed488

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page