a simple, lightweight oauth client
Project description
oauth2py
a simple, lightweight oauth client
require
python 2.7
useage
create client
put config.json in your app folder
from oauth2py.client import OauthClient as oauth github = oauth.load('github')
or set config in code
github.init({ 'client_id': '', 'client_secret': '', 'redirect_uri': '', 'scope': '' })
get login url
url = github.get_login_url(state='abc')
get user info
user = github.get_user_info('code=12345&state=abc') # or user = github.get_user_info({'code': '12345', 'state': 'abc'})
get access token
token = github.get_access_token()
add providers
inherit oauth2py.Oauth2 and set oauth urls
class Github(Oauth2): NAME = 'Github' AUTHORIZATION_URL = 'https://github.com/login/oauth/authorize' ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token' GET_USERINFO_URL = 'https://api.github.com/user' def __init__(self): super(Github, self).__init__()
parse user info from response
def parse_user_info(self, response): return { 'uid': response['id'], 'name': response['name'], 'avatar': response['avatar_url'], 'raw': response }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
oauth2py-1.0.0.tar.gz
(3.9 kB
view details)
File details
Details for the file oauth2py-1.0.0.tar.gz
.
File metadata
- Download URL: oauth2py-1.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7b3c9e5d3254350019d493e0a31f65188a3f41a7e491cf10c3b069ad819296b |
|
MD5 | 29e969389c19c6b6f6928785808031ae |
|
BLAKE2b-256 | dd64c1aa2f8c64775d6c84bacefacc6154b26c5360c2ff3adabdd079089da553 |