spotipie.auth.events

Classes

SessionEvent()

TokenExpiredEvent(session, expired_token, …)

Triggered when the request method is called but the token has expired.

TokenUpdatedEvent(session, old_token, new_token)

Triggered whenever the setter of the token property is called (even if the new token is equal to the old one).

Reference

class spotipie.auth.events.SessionEvent[source]

Bases: abc.ABC

class spotipie.auth.events.TokenExpiredEvent(session, expired_token, withhold_token)[source]

Bases: spotipie.auth.events.SessionEvent

Triggered when the request method is called but the token has expired. The token expiration time is checked before the actual request is made, so a listener to this event can be used to obtain a new token and set the token property of the session so that the request can be carried out without problems. This is handled automatically in refreshable sessions (client credentials and authorization code sessions) but not in the implicit grant session where you must catch this event to implement an “auto-refresh” feature.

Variables
  • session (BaseOAuth2Session) – “BaseOauth2Session”

  • expired_token (spotipie.auth._token.OAuth2Token) – OAuth2Token

  • withhold_token (bool) – bool this is the value of the argument passed to the request method that can be used to prevent the session to refresh its token

Method generated by attrs for class TokenExpiredEvent.

name: ClassVar[str] = 'token_expired'
session: BaseOAuth2Session
expired_token: spotipie.auth._token.OAuth2Token
withhold_token: bool
class spotipie.auth.events.TokenUpdatedEvent(session, old_token, new_token)[source]

Bases: spotipie.auth.events.SessionEvent

Triggered whenever the setter of the token property is called (even if the new token is equal to the old one). This event is guaranteed to be called when a session auto-refreshes its token, so you can listen to this event to save the new token somewhere if you want.

Attributes

session: “BaseOauth2Session” old_token: OAuth2Token new_token: OAuth2Token

Method generated by attrs for class TokenUpdatedEvent.

name: ClassVar[str] = 'token_updated'
session: BaseOAuth2Session
old_token: spotipie.auth._token.OAuth2Token
new_token: spotipie.auth._token.OAuth2Token