swh.web.client.auth module

exception swh.web.client.auth.AuthenticationError[source]

Bases: Exception

Authentication related error.

Example: A bearer token has been revoked.

class swh.web.client.auth.OpenIDConnectSession(oidc_server_url: str = 'https://auth.softwareheritage.org/auth/', realm_name: str = 'SoftwareHeritage', client_id: str = 'swh-web')[source]

Bases: object

Simple class wrapping requests sent to an OpenID Connect server.

Parameters
  • oidc_server_url – URL of OpenID Connect server

  • realm_name – name of the OpenID Connect authentication realm

  • client_id – OpenID Connect client identifier in the realm

login(username: str, password: str) → Dict[str, Any][source]

Login and create new offline OpenID Connect session.

Parameters
  • username – an existing username in the realm

  • password – password associated to username

Returns

The OpenID Connect session info

logout(token: str)[source]

Logout from an offline OpenID Connect session and invalidate previously emitted tokens.

Parameters

token – a bearer token retrieved after login