OAuth support for Asyncio/Trio libraries
Project description
AIOAuth Client – OAuth support for Asyncio / Trio libraries.
Requirements
python >= 3.7
Installation
AIOAuth Client should be installed using pip:
pip install aioauth-client
Usage
# OAuth1
from aioauth_client import TwitterClient
twitter = TwitterClient(
consumer_key='J8MoJG4bQ9gcmGh8H7XhMg',
consumer_secret='7WAscbSy65GmiVOvMU5EBYn5z80fhQkcFWSLMJJu4',
)
request_token, request_token_secret, _ = await twitter.get_request_token()
authorize_url = twitter.get_authorize_url(request_token)
print("Open",authorize_url,"in a browser")
# ...
# Reload client to authorize_url and get oauth_verifier
# ...
print("PIN code:")
oauth_verifier = input()
oauth_token, oauth_token_secret, _ = await twitter.get_access_token(oauth_verifier)
# Save the tokens for later use
# ...
twitter = TwitterClient(
consumer_key='J8MoJG4bQ9gcmGh8H7XhMg',
consumer_secret='7WAscbSy65GmiVOvMU5EBYn5z80fhQkcFWSLMJJu4',
oauth_token=oauth_token,
oauth_token_secret=oauth_token_secret,
)
# Or you can use this if you have initilized client already
# twitter.access_token = oauth_token
# twitter.access_token_secret = oauth_token_secret
timeline = await twitter.request('GET', 'statuses/home_timeline.json')
content = await timeline.read()
print(content)
# OAuth2
from aioauth_client import GithubClient
github = GithubClient(
client_id='b6281b6fe88fa4c313e6',
client_secret='21ff23d9f1cad775daee6a38d230e1ee05b04f7c',
)
authorize_url = github.get_authorize_url(scope="user:email")
# ...
# Reload client to authorize_url and get code
# ...
otoken, _ = await github.get_access_token(code)
# Save the token for later use
# ...
github = GithubClient(
client_id='b6281b6fe88fa4c313e6',
client_secret='21ff23d9f1cad775daee6a38d230e1ee05b04f7c',
access_token=otoken,
)
# Or you can use this if you have initilized client already
# github.access_token = otoken
response = await github.request('GET', 'user')
user_info = await response.json()
Example
Run example with command:
make example
Open http://localhost:5000 in your browser.
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/aioauth-client/issues
Contributing
Development of AIOAuth Client happens at: https://github.com/klen/aioauth-client
License
Licensed under a MIT license.
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
aioauth-client-0.27.2.tar.gz
(14.2 kB
view details)
Built Distribution
File details
Details for the file aioauth-client-0.27.2.tar.gz
.
File metadata
- Download URL: aioauth-client-0.27.2.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72de1d26657388e797670e83487f66d15e057c98393903126790863ab05f0932 |
|
MD5 | ca88976a60934be860b4067fe0d9ec2e |
|
BLAKE2b-256 | 020ac1d257601152ced946cd93c922e3a01f504df81dc3282727fd840854c8a1 |
File details
Details for the file aioauth_client-0.27.2-py3-none-any.whl
.
File metadata
- Download URL: aioauth_client-0.27.2-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1c8470ef02e391025f98efa67d07743f4a84d259da5326e046fa1679917afdc |
|
MD5 | b44d56c3c002a127eaa3eaedca394b48 |
|
BLAKE2b-256 | 79cb8f55f54af264e7c24000dfe7ecf7490dc1c50459a81b92c47fe5ef240a2c |