Skip to main content

nextlayer-sdk-python

Client utilities to interact with next layer public APIs.

Configuration

The module will use a YAML Config file to read it's configuration and also writes to it, to store 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 constructor.

Alternatively the password can be suppliend in the NEXTLAYERSDK_PASSWORD environment variable.

For machine-to-machine authentication (no user account), a client_secret can be supplied instead of username/password - see Client Credentials Grant below.

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},
)
print(rsp.json())

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"https://portal.nextlayer.at/apis/v1",
    auth=NlHttpxAuth(),
)
print(client.get("/users/self").json())

Client Credentials Grant (service accounts)

For machine-to-machine authentication without a user account, supply a client_secret instead of username/password:

nlauth = NlAuth(client_id="your_id", client_secret="topsecret")
access_token = nlauth.get_access_token()

The client_id/client_secret can also be set via the NEXTLAYERSDK_CLIENT_ID/ NEXTLAYERSDK_CLIENT_SECRET environment variables. Whenever a client_secret is present (non-empty), NlAuth auto-detects it and uses the OAuth2 client_credentials grant instead of the password grant - no username is needed or used. It is mutually exclusive with browser_login=True (passing both raises ValueError).

Note: client_secret is deliberately not exposed as a nextlayer-auth CLI flag - command-line arguments are visible to other local users via ps/process listings and get persisted in shell history. Use the environment variable, the config file, or the constructor param instead.

Usage fron commandline

The package also installs a commandline utility nextlayer-auth which takes care of obtaining an access token and printing out a proper Authorization: header.

curl -H "`nextlayer-auth`" https://portal.nextlayer.at/apis/v1/users/self

It can also be used to "logout" by cleaning up tokens in the yaml file with:

nextlayer-auth clear

Metadata

Release files for nextlayer-sdk-python 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nextlayer-sdk-python 1.3.1
File Size Uploaded Provenance Actions
nextlayer_sdk_python-1.3.1.tar.gz 10.7 kB Without provenance Details for nextlayer_sdk_python-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nextlayer-sdk-python 1.3.1
File Interpreter ABI Platform Actions
nextlayer_sdk_python-1.3.1-py3-none-any.whl Python 3 none any Details for nextlayer_sdk_python-1.3.1-py3-none-any.whl

Total release size: 22.7 kB

Release files / nextlayer_sdk_python-1.3.1.tar.gz

Download URL nextlayer_sdk_python-1.3.1.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
164122b24c5eb9992c548d5c1be24c6250b98b7ee47f38d13a748ec0b4b735f6
BLAKE2b-256 checksum
How to use checksums
eeb74783173980c407b4f80264ee6f61af1bb819036d4ba966648ce8b3709df1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.14.7 Linux/6.1.0-45-cloud-amd64

Release files / nextlayer_sdk_python-1.3.1-py3-none-any.whl

Download URL nextlayer_sdk_python-1.3.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5955815c529528ee8c08527637546cf9dc9722b1d4d43d6638113ed976f21292
BLAKE2b-256 checksum
How to use checksums
f41d6f4d9f2f523c256ff3c5f55c959f8d66c4798a46d3123eb2f110c1246208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.14.7 Linux/6.1.0-45-cloud-amd64

Security for nextlayer-sdk-python 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page