Python client for the Eternal-Twin API
Project description
EternalTwin Python Client
eternaltwinpy is an unofficial Python client for the EternalTwin API. It let you authenticate and retrieve users information.
You can view the full documentation at https://eternaltwinpy.readthedocs.io/en/latest/.
Features
- Provides a high-level API to make authorization and user information retrieval easier.
- Provides a low-level API to interact directly with the EternalTwin API.
- Support both synchronous and asynchronous HTTP requests.
Requirements
eternaltwinpy supports the officially supported versions of Python
(mainstream & LTS).
Installation
Install via pip:
pip install eternaltwin
or poetry:
poetry add eternaltwin
Quickstart
Configure the connection
See Configuration for more details.
from eternaltwin.connections import configure
from eternaltwin.keys import HS256Key
ETERNALTWIN_CONFIG = {
"default": {
'url': 'https://eternaltwin.org/api/v1/',
'client_id': "myclient",
'client_secret': 'mysecret',
'redirect_uri': 'https://myapp.com/callback',
'state_key': HS256Key("mykey"),
'allow_redirects': True,
},
"test": {
'url': 'http://localhost:50321/api/v1"',
'client_id': "myclient",
'client_secret': 'mysecret',
'redirect_uri': 'https://localhost:8080/callback',
'state_key': HS256Key("mykey"),
'timeout': 1,
'verify_ssl': False,
}
}
configure(**ETERNALTWIN_CONFIG)
Oauth2 Authorization
See OAuth2 Authorization for more details.
from eternaltwin.users import User
from eternaltwin.exceptions import InvalidStateError
# Generate a state and an authorization URL.
# The state can be used to find which auth request the response corresponds to
# if the callback is handled by a different thread, worker, or process than the
# one that created the auth request.
state, url = User.start_authorization()
# Redirect the user to the url, once authenticated EternalTwin will redirect
# back to your `redirect_uri` with additional query parameters `code` and `state`.
authorization_code = # Extract the `code`
response_state = # Extract the `state`
# Ensure the state is as expected to prevent CSRF attacks.
try:
user = User.from_authorization_code(authorization_code, response_state, state)
except InvalidStateError:
...
assert user.is_authenticated is True
print(user.identifier)
# "<user_id>"
print(user.username)
# "<username>"
Retrieving User Information
See Working with Users for more details.
from eternaltwin.users import User
# Get a specific user by ID
user = User.get("<user_id>")
print(user.identifier)
# "<user_id>"
print(user.username)
# "Bob"
# Search for users by username
users = User.search("Jhon")
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 eternaltwin-1.0.0.tar.gz.
File metadata
- Download URL: eternaltwin-1.0.0.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e54c89f9006f9292e0db6983e4a8fa468f22d672f03940fb9656724fb4eb5d19
|
|
| MD5 |
95a7b8e938d500fa2a0080a1ca207759
|
|
| BLAKE2b-256 |
9d2db17f7d301b442f5bcee9178d5a2d965fa4bc890bb5e2ac02160ae9263f00
|
Provenance
The following attestation bundles were made for eternaltwin-1.0.0.tar.gz:
Publisher:
test_and_publish.yml on qcoumes/eternaltwinpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eternaltwin-1.0.0.tar.gz -
Subject digest:
e54c89f9006f9292e0db6983e4a8fa468f22d672f03940fb9656724fb4eb5d19 - Sigstore transparency entry: 1361480584
- Sigstore integration time:
-
Permalink:
qcoumes/eternaltwinpy@a23a142e8963a36209ecdec4f027eff19d3a29c7 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/qcoumes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_and_publish.yml@a23a142e8963a36209ecdec4f027eff19d3a29c7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file eternaltwin-1.0.0-py3-none-any.whl.
File metadata
- Download URL: eternaltwin-1.0.0-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93d44daf07272f80e4583dba27f3e34045293d214f7558604037a5f34e258f0f
|
|
| MD5 |
1904ff940b95954f2feadb27175cb9f8
|
|
| BLAKE2b-256 |
e3c9c9b4b91cd8c9a3af16857d1bd758e0b8cdd69f4c3baff3b98a41772dad24
|
Provenance
The following attestation bundles were made for eternaltwin-1.0.0-py3-none-any.whl:
Publisher:
test_and_publish.yml on qcoumes/eternaltwinpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eternaltwin-1.0.0-py3-none-any.whl -
Subject digest:
93d44daf07272f80e4583dba27f3e34045293d214f7558604037a5f34e258f0f - Sigstore transparency entry: 1361480588
- Sigstore integration time:
-
Permalink:
qcoumes/eternaltwinpy@a23a142e8963a36209ecdec4f027eff19d3a29c7 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/qcoumes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_and_publish.yml@a23a142e8963a36209ecdec4f027eff19d3a29c7 -
Trigger Event:
release
-
Statement type: