Client utilities to interact with next layer public APIs
Project description
nextlayer-sdk-python
Client utilities to interact with next layer public APIs.
Configuration
The module will use a YAML Config file in , where it also needs to write to, to store
and update the obtained Tokens and their expiry (similar like kubctl does with kubeconfig).
Example ~/.nextlayer-sdk/auth.nlcustomers.yml:
server_url: https://login.nextlayer.at/auth/
realm_name: nlcustomers
client_id: nextlayer-sdk-python
username: foobar
password: topsecret
extra_params:
audience: nextlayer-sdk-python
Except for username, all settings are optional, but if no password is
supplied in config, the password will be asked interactively (if STDIN is a TTY) !
Alternatively the username can be suppled in the NEXTLAYERSDK_USERNAME environment
variable or directly passed to the NlAuth cosntructor.
Alternatively the password can be suppliend in the NEXTLAYERSDK_PASSWORD environment
variable.
Usage
import requests
from nextlayer.sdk.auth import NlAuth
nlauth = NlAuth()
access_token = nlauth.get_access_token()
# make Request to some API Endpoint
rsp = requests.get(
"https://portal.nextlayer.at/apis/v1/users/self",
headers={"Authorization": "Bearer " + access_token},
)
You need to call the .get_access_token() Method every time you make API-Calls,
because it checks if the Token is still valid and will refresh it if necessary.
Usage with httpx
import httpx
from nextlayer.sdk.auth_httpx import NlHttpxAuth
client = httpx.Client(
timeout=httpx.Timeout(30.0),
base_url=f"{base_url}/api/v2",
auth=NlHttpxAuth(),
)
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 nextlayer_sdk_python-1.0.1.tar.gz.
File metadata
- Download URL: nextlayer_sdk_python-1.0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/5.10.0-21-cloud-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eba1cf5b7d444bc91677e047cd507726db4a0329a1f63618cb3d9b33b8d1a5bc
|
|
| MD5 |
1458ef397dfd1bea7b6a8ff24ec94668
|
|
| BLAKE2b-256 |
a628ea45e0de801b9babc6ad09cba3d6b6f0a51caecd6495eefcd96fcc543699
|
File details
Details for the file nextlayer_sdk_python-1.0.1-py3-none-any.whl.
File metadata
- Download URL: nextlayer_sdk_python-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/5.10.0-21-cloud-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e981edaa7b27cf432289cc660d3b9ca49eff47ad10ffb49bac39c866f66bcdf
|
|
| MD5 |
75cc67d328293bb1a2966413e6e520b7
|
|
| BLAKE2b-256 |
48fd0e59b32f105bc4e13d4909868d032d0899910e0ac7bf4ed0dd11f228a440
|