"Login with Discord" support for Starlette and FastAPI.
Project description
Starlette-Discord
"Login with Discord" support for Starlette and FastAPI
starlette-discord is a Discord OAuth2 module intended for use with Starlette and FastAPI.
Installing
starlette-discord can be installed with the command
# Linux
python3 -m pip install -U starlette-discord
# Windows
python -m pip install -U starlette-discord
To install the development version of the library directly from source:
$ git clone https://github.com/nwunderly/starlette-discord
$ cd starlette-discord
$ python3 -m pip install -U .
Quickstart
Below is an example FastAPI app implementing Discord's OAuth flow to identify the user.
import uvicorn
from fastapi import FastAPI
from starlette_discord import DiscordOAuthClient
client_id = "YOUR APP'S CLIENT ID HERE"
client_secret = "YOUR APP'S CLIENT SECRET HERE"
redirect_uri = "http://localhost:8000/callback"
app = FastAPI()
discord_client = DiscordOAuthClient(client_id, client_secret, redirect_uri)
@app.get('/login')
async def start_login():
return discord_client.redirect()
@app.get('/callback')
async def finish_login(code: str):
user = await discord_client.login(code)
print(user)
return user
uvicorn.run(app)
To begin the OAuth authorization flow with this app, visit http://localhost:8000/login
.
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
starlette-discord-0.2.0.tar.gz
(14.1 kB
view hashes)
Built Distributions
starlette_discord-0.2.0-py3.8.egg
(13.4 kB
view hashes)
Close
Hashes for starlette_discord-0.2.0-py3.8.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4db21104c362ad785a7a088c1a31757f7cedad7902c9a827cd7d5429a01d8e27 |
|
MD5 | 58e7477471c70a5be2ac9f8fb32ebc41 |
|
BLAKE2b-256 | 4a8fa5d19e80dff06ffab43eb95fa52095052f54d478d6116937714f2f279b17 |
Close
Hashes for starlette_discord-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eec848e92aeb644ad7e89a650319d1683eeeea7b0a862d45958bea89fca8c837 |
|
MD5 | fa8942d922bc683f4e270582f36c1644 |
|
BLAKE2b-256 | 157b8fbd2e1b229d215f5962566edc414c5f4b6cbd2f3e63f0f8fc72dd211137 |