Simple OAuth library to work with sanic. Basically, just rewrited version of aioauth_client with async/await syntax and some optimization.
Available providers (in alphabetic order):
- Amazon
- BitBucket
- BitBucket v2
- Discord (thanks to @smlbiobot)
- Eventbrite
- Flickr
- Foursquare
- Github
- GitLab
- Meetup
- Naver
- ok.ru
- Plurk
- Tumblr
- Vimeo
- vk.com
- Yahoo
- Yandex
- python >= 3.6
- Download Zip of this repository: https://github.com/TrulyBright/sanic-oauth/archive/master.zip
- Install via pip:
pip install <path_to_the_zip_file>
Note, that to use blueprint correctly, you need to additionally install sanic>=20.0
and sanic-session
.
Simple way for use this is blueprint with oauth configuration.
But, before use it you need to:
- Create
aiohttp.ClientSession
and bind to app likeasync_session
variable. - Create session interface from
sanic-session
package and bind it to app likesession_interface
variable. - Configure
app.config
settings. You should passOAUTH_PROVIDER, OAUTH_REDIRECT_URI, OAUTH_SCOPE
and another settings, for example,OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET
. Every setting withOAUTH
prefix will be passed to oauth provider construction. - Apply blueprint
- Add decorator
login_required
to routes, that required oauth.
You can see example for more details.
If you don't like current blueprint, you always can use providers directly and implements you own logic, like in old_example.