OAuth support for Asyncio/Trio libraries
Project description
AIOAuth Client – OAuth support for Asyncio / Trio libraries.
Requirements
python >= 3.9
Installation
AIOAuth Client should be installed using pip:
pip install aioauth-client
Usage
# 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()
# OAuth1
from aioauth_client import TwitterClient
twitter = TwitterClient(
consumer_key='J8MoJG4bQ9gcmGh8H7XhMg',
consumer_secret='7WAscbSy65GmiVOvMU5EBYn5z80fhQkcFWSLMJJu4',
)
request_token, _ = 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, data = await twitter.get_access_token(oauth_verifier)
oauth_token_secret = data.get('oauth_token_secret')
# 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)
Example
Run example with command:
make example
Open http://localhost:8080 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aioauth_client-0.30.1.tar.gz.
File metadata
- Download URL: aioauth_client-0.30.1.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
718b1f7f2030254902d7cad7f4980ae5b0b56755d2c3be7f6befef406948d425
|
|
| MD5 |
36a970f8e8adc7924cc9668c8922010b
|
|
| BLAKE2b-256 |
31a5423a175b41e9aa811a58defa566e9f9f7e3a76e060881ab19db426edb646
|
File details
Details for the file aioauth_client-0.30.1-py3-none-any.whl.
File metadata
- Download URL: aioauth_client-0.30.1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
806df0ddd31923952eaf8203bcdf1703331098a59a62e02640321e22c0c00015
|
|
| MD5 |
580302b565e55ed5eb59d90b09ea5075
|
|
| BLAKE2b-256 |
f4d22314eebd58b904178dc6ae59a492e729288f40375201a4c96fb40b19d746
|