Skip to main content

An asynchronous discord OAuth2 API wrapper.

Project description

Discord OAuth2

Documentation Status Pypi version PyPi downloads Code style: Black

A modern, easy to use discord OAuth2 API wrapper written in Python.

Installing

Python >3.8 is required.

You can run the following command to install the library:

$ pip install disco.oauth2

To install the development version (lastest), do the following:

$ pip install git+https://github.com/InviteManagerBot/disco.oauth2.git

Getting started

Quick Example

from disco_oauth2 import Client

client = Client(
    client_id=client_id_here,
    client_secret="client_secret_here",
    redirect_uri="redirect_uri_here",
    scopes=["identify", "guilds", "email", "connections"],
)


async def main():
    # Exchange a code received from the callback from the redirect url.
    access_token = await client.exchange_code("my_code")

    # Fetch user's information with access token.
    user = await client.fetch_user(access_token)

    # Fetch user's connections.
    connections = await user.fetch_connections()

    # Fetch guilds that the user is member of.
    guilds = await user.fetch_guilds()

    print(f"{user!r} | {connections!r}")

    for guild in guilds:
        print(f"`{user.name}` member of {guild!r}")

Requirements

  • aiohttp > = 3.7.4, < 4

Optionally you may install the orjson libraries (highly recommended for sake of speed).

License

discord_oauth2 was written by martimartins martim13artins13@gmail.com, licensed under the MIT license.

Contributing

All contributions are welcome ;)

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

disco.oauth2-1.3b0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

disco.oauth2-1.3b0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file disco.oauth2-1.3b0.tar.gz.

File metadata

  • Download URL: disco.oauth2-1.3b0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for disco.oauth2-1.3b0.tar.gz
Algorithm Hash digest
SHA256 95787ee12a5a7103a531c623ae94528583125d3d59040fae739db3f66583cfd1
MD5 fc16db69caa630cfc68899265e446303
BLAKE2b-256 022d19dc25e8a61f22e738681a4f6d33757d168d574d7ef4d6e148c1e86db3fa

See more details on using hashes here.

File details

Details for the file disco.oauth2-1.3b0-py3-none-any.whl.

File metadata

  • Download URL: disco.oauth2-1.3b0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for disco.oauth2-1.3b0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1d64169c649a46fcb3445585238b03d6c4551b3a53827bbfa8c637385311b99
MD5 2d3d45aeca5593834a14b2cd5f4282ae
BLAKE2b-256 0721492304d67a835fac0a0eec94679cfeb77006b92809b15834acb9968a6bd8

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