An async wrapper for the Discord Oauth2 API
Project description
Discord.Web
An asynchronous wrapper for the Discord Oauth2 API
Explore the docs »
Table of Contents
About The Project
Discord-Web is an easy way to interface with the Discord Oauth api. If you're new the realm of developing for discord, you may not know what the Oauth2 api may be used for. Well, a good example would be a Login backend on your bot's website to allow for some advanced dashboard creation. Creating these requests yourself can be time-consuming! Here's where Discord-Web comes into play. We handle the requests for you, returning easy to manage Python Objects such as the Oauth2Member
object and the Oauth2Guild
.
Built With
Getting Started
Welcome to the Getting Started Section. Here, we explain how you can get started with the discord-web
library.
Prerequisites
Here's a list of prerequisites that you will need for the discord-web library to work. Keep in mind that all of these (with the exception of aiohttp[speedups]
) are installed when installing discord.web
- discord.py
pip install discord.py
- aiohttp
pip install aiohttp
Installing the speedups for aiohttp
If you wish, you can install the speedups package for aiohttp, which allows aiohttp to run requests much faster.
- aiohttp speedups
pip install aiohttp[speedups]
Installation
Installing the discord.web
library is a breeze. Here we list both ways of installing the library (the stable version and the development version)
pip install discord.web
pip install git+https://github.com/quiktea/discord.web/
Usage
First of all, you need to create an application on the Discord Developer Portal. Once you do that, click on the OAuth2 tab and follow the example below:
Initialising an OAuth2 Client
To initialise an OAuth2 Client, simply follow the example below:
from discord_web.oauth2 import Oauth2Client
client = Oauth2Client(client_id, "client_secret", "redirect_uri", ["scope1", "scope2"])
Generating an Access Token
To access a user's info, you need what's called an Access Token
. To get an access token, you first need the code given to you by the OAuth2 login url that you created on the Discord Developer Portal. After a user logins in using your URL, they will be redirected to the redirect_uri
that you provided on the Developer Portal. After getting redirected, the URL on your end will be returned with the code
URL parameter, which looks like so: https://example.com/?code=CODE
. You will need to access this code. In Django, you would access it like so: request.GET.get("code")
. This is the code that you pass into the exchange_code
function. The function will then return an AccessToken
object which holds information such as the refresh_token
and the access_token
. To access the access token, simply reference the access_token
property of your AccessToken class.
For more examples, please refer to the Documentation
Roadmap
See the open issues for a list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Discord - discord.web - https://discord.gg/JmhWrK99GS
Project Link: https://github.com/quiktea/discord.web
Acknowledgements
Project details
Release history Release notifications | RSS feed
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.web-0.0.2.tar.gz
.
File metadata
- Download URL: discord.web-0.0.2.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/54.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fcb235523312d5ff53d8a36e0674dfa75eba781007cfe745ff5a7c30442d7a9 |
|
MD5 | de56d4a581730ef7702a830a3329f4b4 |
|
BLAKE2b-256 | 28d33003a473399b49510e287ec62a3861c7c8798ee22067af4d57b022e31a9e |
File details
Details for the file discord.web-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: discord.web-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/54.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca7c54e76f4069566adcc300638f61a8afc85fbc140346fedf3fa798dd523209 |
|
MD5 | 809e50356702de57c5ef3edbeccb1759 |
|
BLAKE2b-256 | bcfcbe73a675aeb2773e966de666f7ac7a23243fac6637a5ad25c6e1454567be |