Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/staciax/github-oauth2
A basic github oauth2 for python.
https://github.com/staciax/github-oauth2
asyncio github oauth2 python
Last synced: about 1 month ago
JSON representation
A basic github oauth2 for python.
- Host: GitHub
- URL: https://github.com/staciax/github-oauth2
- Owner: staciax
- License: mit
- Created: 2024-06-01T14:45:37.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-06-01T14:47:01.000Z (8 months ago)
- Last Synced: 2024-12-06T03:27:30.479Z (about 2 months ago)
- Topics: asyncio, github, oauth2, python
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Github OAuth2 Client
A simple Github OAuth2 client for Python.## Installation
```bash
pip install git+https://github.com/staciax/github-oauth2.git
```## Quick Example with FastAPI
```python
from fastapi import FastAPI
from starlette.responses import RedirectResponsefrom github_oauth2 import GithubOAuth2Client
from github_oauth2.utils import oauth2_urlapp = FastAPI()
github_client_id = 'client_id'
github_client_secret = 'client_secret'@app.get('/github-login')
async def github_login() -> RedirectResponse:
url = oauth2_url(client_id=github_client_id, scope='user:email')
return RedirectResponse(url, status_code=302)@app.get('/github-code')
async def github_code(code: str) -> dict:
client = GithubOAuth2Client(
client_id=github_client_id,
client_secret=github_client_secret,
)
data = await client.get_access_token(code=code, scope='user:email')
user = await client.get_user(access_token=data['access_token'])return user
```
## License
MIT