auth

  • Functions for interacting with authentication tokens to use with the API

  • Also contains variables and functions intended for internal use

class DedicatedServerToken(audience: str, access_token: str, refresh_token: str, expiration: int = 0)[source]

Bases: WebServicesToken

Parameters:
  • audience (str) –

    • audience for which token is valid

  • access_token (str) –

    • main token used for authorization

  • refresh_token (str) –

    • token used to refresh access token

  • expiration (int) –

    • time at which access token will expire

    • if not given, will be decoded from the token’s payload

    • default: 0

static get(audience: str, login: str, password: str, agent: str) DedicatedServerToken[source]
  • requests a dedicated server account token for a given audience

Parameters:
  • audience (str) –

    • desired audience for token use

    • capitalization is ignored

    • valid: ‘NadeoServices’/’core’/’prod’, ‘NadeoLiveServices’/’live’/’meet’/’club’

  • login (str) –

    • dedicated server account username

  • password (str) –

    • dedicated server account password

  • agent (str) –

    • user agent, ideally with your program’s name and a way to contact you

    • Nadeo can block your request without this being properly set

class JSONWebToken(token: str)[source]

Bases: object

  • a JSON web token in a base64-encoded string

static decode(token: str) dict[source]
  • decodes a JSON web token into a dictionary using its payload section

  • will fail if passed an invalid token

decoded: dict
token: str
class OAuthToken(identifier: str, secret: str, access_token: str, expiration: int = 0)[source]

Bases: Token

Parameters:
  • identifier (str) –

    • client ID (username)

  • secret (str) –

    • client secret (password)

  • access_token (str) –

    • main token used for authorization

  • expiration (int) –

    • time at which access token will expire

    • if not given, will be decoded from the token’s payload

    • default: 0

static check_type(token: Token, msg: str = '') None[source]
  • checks that a token is for OAuth2 and throws a UsageError otherwise

Parameters:
  • token (Token) –

    • authentication token

  • msg (str) –

    • exception message to pass along if the check fails

    • default: ‘’ (empty)

static get(identifier: str, secret: str) OAuthToken[source]
  • requests an authentication token

Parameters:
  • identifier (str) –

    • username

  • secret (str) –

    • password

identifier: str
refresh() None[source]
  • refreshes token

  • doesn’t actually refresh, rather this requests a new token

secret: str
class ServiceToken(audience: str, access_token: str, refresh_token: str, expiration: int = 0)[source]

Bases: WebServicesToken

Parameters:
  • audience (str) –

    • audience for which token is valid

  • access_token (str) –

    • main token used for authorization

  • refresh_token (str) –

    • token used to refresh access token

  • expiration (int) –

    • time at which access token will expire

    • if not given, will be decoded from the token’s payload

    • default: 0

account_id: str
static check_type(token: Token, msg: str = '') None[source]
  • checks that a token is for a service account and throws a UsageError otherwise

Parameters:
  • token (Token) –

    • authentication token

  • msg (str) –

    • exception message to pass along if the check fails

    • default: ‘’ (empty)

static get(audience: str, login: str, password: str, agent: str) ServiceToken[source]
  • requests a service account token for a given audience

Parameters:
  • audience (str) –

    • desired audience for token use

    • capitalization is ignored

    • valid: ‘NadeoServices’/’core’/’prod’, ‘NadeoLiveServices’/’live’/’meet’/’club’

  • login (str) –

    • service account username

  • password (str) –

    • service account password

  • agent (str) –

    • user agent, ideally with your program’s name and a way to contact you

    • Nadeo can block your request without this being properly set

class Token(audience: str, access_token: str, expiration: int = 0)[source]

Bases: object

  • a general authentication token

  • does not contain a base URL as a token could be used for multiple

Parameters:
  • audience (str) –

    • audience for which token is valid

  • access_token (str) –

    • main token used for authorization

  • refresh_token (str) –

    • token used to refresh access token (if applicable)

    • default: ‘’ (empty)

  • expiration (int) –

    • time at which access token will expire

    • if not given, will be decoded from the token’s payload

    • default: 0

access_token: JSONWebToken
audience: str
expiration: int
property expired: bool
refresh() None[source]
  • refreshes token(s)

static verify_audience(audience: str) str[source]
class WebServicesToken(audience: str, access_token: str, refresh_token: str, expiration: int = 0)[source]

Bases: Token

  • a token for the private web services API

Parameters:
  • audience (str) –

    • audience for which token is valid

  • access_token (str) –

    • main token used for authorization

  • refresh_token (str) –

    • token used to refresh access token

  • expiration (int) –

    • time at which access token will expire

    • if not given, will be decoded from the token’s payload

    • default: 0

check_audience(audience: str) None[source]
  • checks that the token has the expected audience and throws an AudienceError otherwise

Parameters:
  • token (WebServicesToken) –

    • authentication token

  • audience (str) –

    • expected audience

static check_type(token: Token, msg: str = '') None[source]
  • checks that a token is for web services and throws a UsageError otherwise

Parameters:
  • token (Token) –

    • authentication token

  • msg (str) –

    • exception message to pass along if the check fails

    • default: ‘’ (empty)

static get(audience: str, login: str, password: str, agent: str) WebServicesToken[source]
  • requests a web services token for a given audience

  • this token is not useful on its own, instead use a token for a specific account type

Parameters:
  • audience (str) –

    • desired audience for token use

    • capitalization is ignored

    • valid: ‘NadeoServices’/’core’/’prod’, ‘NadeoLiveServices’/’live’/’meet’/’club’

  • login (str) –

    • account username

  • password (str) –

    • account password

  • agent (str) –

    • user agent, ideally with your program’s name and a way to contact you

    • Nadeo can block your request without this being properly set

refresh() None[source]
  • refreshes access and refresh tokens

refresh_token: JSONWebToken