package documentation

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:

  1. 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.
  2. 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.
  3. The helper receives an authorization response containing an access token
    and expiry. The receiver converts this into a nebius.aio.token.token.Token and returns it to the caller.

Where the URL is shown

  • The authorization URL is logged at INFO/DEBUG levels so it appears in the project's
    logs.
  • If Receiver or Bearer has a writer, the helper writes the URL and short instructions to it. The caller can then show them to the user, for example on stdout.

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

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_wsl 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 Bearer that exposes a federation interactive receiver.
Class Receiver Receiver that runs the federation interactive authorization.
Type Variable T Undocumented
Variable log Undocumented

Undocumented

Value
TypeVar('T')

Undocumented