openbankproject_client.auth module

Authentication utilities for the OpenBankProject API Client.

class openbankproject_client.auth.DirectLoginAuth(username: str | None = None, password: str | None = None, consumer_key: str | None = None, token: str | None = None)[source]

Bases: object

Authentication handler for DirectLogin authentication method.

__init__(username: str | None = None, password: str | None = None, consumer_key: str | None = None, token: str | None = None)[source]

Initialize DirectLogin authentication.

Parameters:
  • username – User’s username (required if token not provided)

  • password – User’s password (required if token not provided)

  • consumer_key – Consumer key for the application (required if token not provided)

  • token – Pre-generated DirectLogin token (optional)

get_headers() Dict[str, str][source]

Get authentication headers.

Returns:

Dict containing the Authorization header

authenticate(client) bool[source]

Authenticate with the API and get a token if needed.

Parameters:

client – OpenBankProjectClient instance

Returns:

True if authentication was successful

class openbankproject_client.auth.GatewayLoginAuth(token: str)[source]

Bases: object

Authentication handler for GatewayLogin authentication method.

__init__(token: str)[source]

Initialize GatewayLogin authentication.

Parameters:

token – GatewayLogin JWT token

get_headers() Dict[str, str][source]

Get authentication headers.

Returns:

Dict containing the Authorization header

authenticate(client) bool[source]

Authenticate with the API.

Parameters:

client – OpenBankProjectClient instance

Returns:

True if authentication was successful

class openbankproject_client.auth.Authentication[source]

Bases: object

Authentication utilities for the OpenBankProject API.

static create_direct_login_header(username: str, password: str, consumer_key: str) Dict[str, str][source]

Create a DirectLogin authorization header.

Parameters:
  • username – User’s username

  • password – User’s password

  • consumer_key – Consumer key for the application

Returns:

Dict containing the Authorization header

static create_gateway_login_header(jwt: str) Dict[str, str][source]

Create a GatewayLogin authorization header.

Parameters:

jwt – JSON Web Token for authentication

Returns:

Dict containing the Authorization header

static create_token_header(token: str, auth_type: str = 'DirectLogin') Dict[str, str][source]

Create an authorization header using a token.

Parameters:
  • token – Authentication token

  • auth_type – Authentication type (DirectLogin or GatewayLogin)

Returns:

Dict containing the Authorization header

static generate_jwt(consumer_key: str, consumer_secret: str, user_id: str | None = None, expiry_seconds: int = 3600) str[source]

Generate a JWT token for GatewayLogin.

This is a simplified implementation and may need to be adjusted based on the specific requirements of the OpenBankProject API.

Parameters:
  • consumer_key – Consumer key for the application

  • consumer_secret – Consumer secret for the application

  • user_id – Optional user ID to include in the token

  • expiry_seconds – Token expiry time in seconds (default: 1 hour)

Returns:

JWT token string