Federated bearer allowing interactive authorization flows.
This module provides a small bearer implementation that performs an interactive federation-based authorization to obtain short-lived access tokens. It is intended for scenarios where a user needs to authorize a local client by opening a browser or presenting a URL to the user.
Interactive authorization flow (what happens on fetch)
When Receiver._fetch starts, it calls
nebius.aio.token.federation_bearer.auth.authorize. This function
performs the interactive federation handshake:
- The helper constructs an authorization URL and either attempts to open
- the user's default browser or returns the URL for the caller to display.
- The helper will block while waiting for the user to complete the
- authorization in the browser (for example by granting access). This means Receiver._fetch may hang until the user completes the flow.
- The helper receives an authorization response containing an access token
- and expiry. The receiver converts this into a
nebius.aio.token.token.Tokenand returns it to the caller.
Where the URL is shown
Blocking considerations
Because the flow waits for the user's action, callers should be aware that
fetch can block for an extended period. Use reasonable timeouts when
calling Receiver._fetch or invoke the bearer within a background
task if you need the application to remain responsive.
Classes
Receiver-- A receiver that executes the interactive- authorization flow and returns a
nebius.aio.token.token.Token.
Bearer-- A small bearer wrapper exposing the receiver and a- canonical
Bearer.nameused for caching and logging.
Example
Construct a bearer and fetch a token:
bearer = Bearer(profile_name, client_id, endpoint, federation_id) token = await bearer.receiver().fetch()
| Module | auth |
Federation bearer authentication utilities. |
| Module | constants |
Undocumented |
| Module | is |
No module docstring; 1/1 function documented |
| Module | pkce |
No module docstring; 1/1 function, 1/1 class documented |
| Module | server |
Federation bearer token server for handling OAuth callbacks. |
From __init__.py:
| Class | |
Bearer that exposes a federation interactive receiver. |
| Class | |
Receiver that runs the federation interactive authorization. |
| Type Variable | T |
Undocumented |
| Variable | log |
Undocumented |