Skip to main content

A basic wrapper discord oauth2

Project description

Auth Cord

discord pypi license

Python Wrapper for discords oauth2

Key Features

Support for the following endpoints
- exchange code for token
- refresh token
- get user connections
- get user guilds
- get user info

Installing

Python 3.8 or higher is required Install from pip
python -m pip install -U auth-cord

Install from github

python -m pip install -U git+https://github.com/cibere/auth-cord # requires git to be installed

FAQ

Q: I don't have a webserver, can I still use discords oauth?
A: Yes! You can set the redirect_url to https://api.cibere.dev/auth_cord, and tell the user to give your bot the given code.

Examples

Get user info
import asyncio

import auth_cord

# creating our authorization object
auth = auth_cord.Authorization(
    client_id=123,
    client_secret="...",
    redirect_url="...",
)

# creating our client instance and passing our authorization
client = auth_cord.Client(authorization=auth)


async def main():
    # starting our client
    async with client:
        # exchanging our code with discord for a token
        token = await client.exchange_code("...")

        # getting the users connections
        user = await client.get_user_info(
            token.token
        )  # 'token' is a 'auth_cord.token.Token' object

        # printing the users id
        print(user.id)


# checking if this file is the one that was run
if __name__ == "__main__":
    # if so, run the main function
    asyncio.run(main())

See the examples folder for a full list of examples

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

auth_cord-0.1.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

auth_cord-0.1.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file auth_cord-0.1.2.tar.gz.

File metadata

  • Download URL: auth_cord-0.1.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for auth_cord-0.1.2.tar.gz
Algorithm Hash digest
SHA256 57c8032cafc0a69849293b7ff201c789205497cbd2993291bf63f7850bc675cc
MD5 e255ef51779db2c19454f4576f4e3ada
BLAKE2b-256 675c28ebc4ed3de97cf887ec6a5bf74f4ec7bcabc11b23a43932332725639ae1

See more details on using hashes here.

File details

Details for the file auth_cord-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: auth_cord-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for auth_cord-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2324edce2926dc2fae46393feec5b7e2bcd40ba3e4ef2b7bded6fb519dcc37e1
MD5 5b89db4256d29be229455f6208357625
BLAKE2b-256 dc9640578379dc598c738892208e14ee9af668f3bd337bfb8cc45a611522ed49

See more details on using hashes here.

Supported by

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