OAuth support for Asyncio/Trio libraries
Project description
AIOAuth Client – OAuth support for Asyncio / Trio libraries.
Requirements
python >= 3.8
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.25.8.tar.gz
(12.6 kB
view details)
Built Distribution
File details
Details for the file aioauth-client-0.25.8.tar.gz
.
File metadata
- Download URL: aioauth-client-0.25.8.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99b8e6174dfa26137cee0be75a9afa1ff55ebf0bb172af89b3722d9d6c8b3546 |
|
MD5 | 9aa3999af255b4fdf141da38a03e9486 |
|
BLAKE2b-256 | c4e20e84168879405c4631b0a2fb54c6181ccb8623d589af1afc1ac5c27e1d13 |
File details
Details for the file aioauth_client-0.25.8-py3-none-any.whl
.
File metadata
- Download URL: aioauth_client-0.25.8-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c5d0841d5f26178b08ab90a183db34fb36394b39355916f6cd6745f5d1f9844 |
|
MD5 | b8f42af8a490262290e22a9cd32e3709 |
|
BLAKE2b-256 | d94b34780f1ba38a14c1b886a35288bb73836c8416f1cc34a9a1d877dcddc320 |