ds_stoa.authentication

This module provides authentication and RESTful API interaction capabilities for the Stoa API.

It includes two primary functions:

  • oauth2: For obtaining OAuth2 authentication tokens necessary for secure API access. This function uses client ID and client secret to authenticate.

  • rest: For making authenticated RESTful API requests to various endpoints within the Stoa API. This function uses email and password for authentication, differing from the oauth2 method which uses client credentials.

These functions facilitate secure and efficient communication with the Stoa API, enabling the exchange of data through authenticated requests.

Example usage:

from ds_stoa.authentication import oauth2, rest

token = oauth2(
    client_id="your_client_id",
    client_secret="your_client_secret",
)

token = rest(
    email="your_email",
    password="your_password",
)

Submodules

Functions

oauth2(→ str)

Authenticates an application and retrieves an access token.

rest(→ str)

Authenticates a user and retrieves an access token.

Package Contents

ds_stoa.authentication.oauth2(client_id: str, client_secret: str) str[source]

Authenticates an application and retrieves an access token.

Parameters:
  • client_id (str) – The Client ID.

  • client_secret (str) – The Client Secret.

Returns:

An access token indicating successful authentication.

Return type:

str

Example:

>>> oauth2('client_id', 'client_secret')
'access_token_value'
ds_stoa.authentication.rest(email: str, password: str) str[source]

Authenticates a user and retrieves an access token.

Parameters:
  • email (str) – The email of the user.

  • password (str) – The password of the user.

Returns:

An access token indicating successful authentication.

Return type:

str

Example:

>>> rest('user@example.com', 'secret')
'access_token_value'