Skip to main content

An async wrapper for the Discord Oauth2 API

Project description

Contributors Forks Stargazers Issues MIT License


Logo

Discord.Web

An asynchronous wrapper for the Discord Oauth2 API
Explore the docs »

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgements

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: OAuth2 Example

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord.web-0.0.2.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

discord.web-0.0.2-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

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