AuthHandler class — Twitcasting API Authentication

Authentication header

AuthHandler

class twitcaspy.auth.auth.AuthHandler(client_id, client_secret)

AuthHandler Base Class

Parameters
  • client_id (str) – client_id of this app

  • client_secret (str) – client_secret of this app

Raises

TypeError – If the given client id and/or secret is not a string instance

Application-only authentication handler

class twitcaspy.auth.AppAuthHandler(client_id, client_secret)

Bases: twitcaspy.auth.auth.AuthHandler

Application-only authentication handler

Parameters
  • client_id (str) – client_id of this app

  • client_secret (str) – client_secret of this app

References

https://apiv2-doc.twitcasting.tv/#access-token

Authorization Code Grant handler

class twitcaspy.auth.GrantAuthHandler(client_id, client_secret, callback=None, *, state=None)

Bases: twitcaspy.auth.auth.AuthHandler

Authorization Code Grant handler

Parameters
  • client_id (str) – client_id of this app

  • client_secret (str) – client_secret of this app

  • callback (str) – Specify the same Callback URL set when registering the application.

  • state (str) – CSRF token

References

https://apiv2-doc.twitcasting.tv/#authorization-code-grant

get_authorization_url()

Get the authorization URL to redirect the user

set_access_token(bearer_token)
Set bearer_token.
Parameters

bearer_token (str) – bearer_token to use

Returns

Return type

None

Implicit handler

class twitcaspy.auth.ImplicitAuthHandler(client_id, client_secret, callback=None, *, state=None)

Bases: twitcaspy.auth.auth.AuthHandler

Implicit Code Grant handler

Parameters
  • client_id (str) – client_id of this app

  • client_secret (str) – client_secret of this app

  • callback (str) – Specify the same Callback URL set when registering the application.

  • state (str) – CSRF token

References

https://apiv2-doc.twitcasting.tv/#implicit

get_authorization_url()

Get the authorization URL to redirect the user

set_access_token(bearer_token)
Set bearer_token.
Parameters

bearer_token (str) – bearer_token to use

Returns

Return type

None

OAuth2

Basic Authentication

class twitcaspy.auth.oauth.OAuth2Basic(client_id, client_secret)

Bases: requests.auth.AuthBase

Basic Authentication

Parameters
  • client_id (str) – client_id of this app

  • client_secret (str) – client_secret of this app

Raises

TypeError – If the given client id and/or secret is not a string instance

Bearer Authentication

class twitcaspy.auth.oauth.OAuth2Bearer(bearer_token)

Bases: requests.auth.AuthBase

Bearer Authentication

Parameters

bearer_token (str) – Bearer Token of this user.

Raises

TypeError – If the given bearer_token is not a string instance