https://github.com/pysnippet/fastapi-oauth2
Easy to integrate OAuth2 authentication with support for several identity providers.
https://github.com/pysnippet/fastapi-oauth2
allauth auth authentication fastapi login middleware oauth oauth2 python security social sso
Last synced: 4 days ago
JSON representation
Easy to integrate OAuth2 authentication with support for several identity providers.
- Host: GitHub
- URL: https://github.com/pysnippet/fastapi-oauth2
- Owner: pysnippet
- License: mit
- Created: 2023-06-13T14:17:23.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-20T08:37:38.000Z (about 1 year ago)
- Last Synced: 2025-09-25T16:08:29.647Z (4 months ago)
- Topics: allauth, auth, authentication, fastapi, login, middleware, oauth, oauth2, python, security, social, sso
- Language: Python
- Homepage: https://docs.pysnippet.org/fastapi-oauth2
- Size: 254 KB
- Stars: 84
- Watchers: 1
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastapi-oauth2 
[](https://pypi.org/project/fastapi-oauth2/)
[](https://playground.pysnippet.org/fastapi-oauth2/)
[](https://pypi.org/project/fastapi-oauth2/)
[](https://pypi.org/project/fastapi-oauth2/)
[](https://github.com/pysnippet/fastapi-oauth2/actions/workflows/tests.yml)
[](https://github.com/pysnippet/fastapi-oauth2/actions/workflows/docs.yml)
FastAPI OAuth2 is a middleware-based social authentication mechanism supporting several OAuth2 providers. It leverages
the [social-core](https://github.com/python-social-auth/social-core) authentication backends and integrates seamlessly
with FastAPI applications.
## Integration
For integrating the package into an existing FastAPI application, the router with OAuth2 routes and
the `OAuth2Middleware` with particular [configs](https://docs.pysnippet.org/fastapi-oauth2/integration/configuration)
should be added to the application.
```python
from fastapi import FastAPI
from fastapi_oauth2.middleware import OAuth2Middleware
from fastapi_oauth2.router import router as oauth2_router
app = FastAPI()
app.include_router(oauth2_router)
app.add_middleware(OAuth2Middleware, config=OAuth2Config(...))
```
## Contribute
Any contribution is welcome. Always feel free to open an issue or a discussion if you have any questions not covered by
the documentation. If you have any ideas or suggestions, please, open a pull request. Your name will shine in our
contributors' list. Be proud of what you build!
## License
Copyright (C) 2023 Artyom Vancyan. [MIT](https://github.com/pysnippet/fastapi-oauth2/blob/master/LICENSE)