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.
Release files for aioauth-client 0.30.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aioauth_client-0.30.1.tar.gz | 12.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aioauth_client-0.30.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / aioauth_client-0.30.1.tar.gz
| Download URL | aioauth_client-0.30.1.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
718b1f7f2030254902d7cad7f4980ae5b0b56755d2c3be7f6befef406948d425
|
|
BLAKE2b-256 checksum How to use checksums |
31a5423a175b41e9aa811a58defa566e9f9f7e3a76e060881ab19db426edb646
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure
|
Release files / aioauth_client-0.30.1-py3-none-any.whl
| Download URL | aioauth_client-0.30.1-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
806df0ddd31923952eaf8203bcdf1703331098a59a62e02640321e22c0c00015
|
|
BLAKE2b-256 checksum How to use checksums |
f4d22314eebd58b904178dc6ae59a492e729288f40375201a4c96fb40b19d746
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure
|