Token

class cordy.auth.Token(token: str, bot: bool = False)[source]

Represents an API token.

Only Bot and Bearer Tokens are supported. User tokens are not supported

token

The token string without any prefixes like “Bot” or “Bearer”

Type

str

get_auth() str[source]

Return the authorization header for the token

Returns

The authorization header value.

Return type

str

property bot: bool

Whether the token is a bot token

Type

bool

property bearer: bool

Whether the token is an oauth bearer token. This is always the negation of Token.bot

Type

bool

classmethod from_auth(auth: str) cordy.auth.Token[source]

Build a Token from an auth header format.

Parameters

auth (str) – The authorization header format string.

Returns

The token built from the auth header value.

Return type

Token

Raises

ValueError – Format of the auth parameter is incorrect.