spotifywebapipython.spotifyauthtoken

class SpotifyAuthToken:

Spotify Authorization Token class.

SpotifyAuthToken(authorizationType: str, profileId: str, root: dict = None)

Initializes a new instance of the class.

Arguments:
  • authorizationType (str): Authorization type chosen when this token was generated.
  • profileId (str): Profile identifier used when loading / storing the token to disk.
  • root (dict): Spotify Web API JSON response in dictionary format, used to load object attributes; otherwise, None to not load attributes.
AccessToken: str

An access token that can be provided in subsequent calls to Spotify Web API services.

AuthorizationType: str

Authorization type chosen when this token was generated.

It will be one of the following values:

  • "Authorization Code".
  • "Authorization Code with PKCE".
  • "Client Credentials".
  • "Implicit Grant".
def CreateDateTimeUtc(self) -> datetime.datetime:

DateTime (in UTC format) that the authorization token was created.

ExpireDateTimeUtc: datetime.datetime

DateTime (in UTC format) that the authorization token will expire.

ExpiresIn: int

The time period (in seconds) for which the access token is valid.

ExpiresAt: int

DateTime (in epoch seconds) that the authorization token will expire.

HeaderKey: str

Returns a string containing the header key to assign the authorization token value to. This will always return 'Authorization'.

HeaderValue: str

Returns the value portion of the authorization header, in the form of '{tokentype} {token}'.

Example: `Bearer {token value ...}'

IsExpired: bool

Returns true if the token has expired; otherwise, False if not expired.

ProfileId: str

Profile identifier used when loading / storing the token to disk.

RefreshToken: str

The refresh token returned from the authorization token request.

This is only set when using the "Authorization code" or "Authorization code with PKCE" authorization types.

There will be no refresh token for the "Client Credentials" or "Impllicit Grant" authorization types.

Scope: str

A space-separated list of scopes which have been granted for the AccessToken.

If no scopes are specified, authorization will be granted only to access publicly available information: that is, only information normally visible in the Spotify desktop, web, and mobile players.

Scopes can only be used with the "Authorization Code", "Authorization Code with PKCE", and "Implicit Grant" authorization types.

Scopes cannot be used with the "Client Credentials" authorization type.

Scopes: list[str]

A list of scopes which have been granted for the AccessToken.

TokenType: str

How the access token may be used: always "Bearer" in this case.

def ToString(self) -> str:

Returns a displayable string representation of the class.