"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.1.0.tar.gz
(10.3 kB
view hashes)
Built Distributions
starlette_discord-0.1.0-py3.8.egg
(19.6 kB
view hashes)
Close
Hashes for starlette_discord-0.1.0-py3.8.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | b753067a047716a26af99626d7a7064957b5883e6314659d0c78676a310ae2a0 |
|
MD5 | 1cd794fc0b9b5ae851c09cf2f7e3e798 |
|
BLAKE2b-256 | 784c72ec922e940fb56d5aa7abec5c81065bf0a4a4c7ea9464bd38b470afa5a0 |
Close
Hashes for starlette_discord-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07ae4ab20407842ea48ae5282f77d494411d68486bd28593172603c790254c30 |
|
MD5 | 2f6e41381898fb1ec97a7e7ce241f0b7 |
|
BLAKE2b-256 | f6b8c6f5c44d4f926c7a10a43c5fa2e3617626ae8cf69ca18739cb6b2fc4c309 |