TokenCredential Class

Represents a token credential that is used to authorize HTTPS requests. The token can be updated by the user.

Inheritance
builtins.object
TokenCredential

Constructor

TokenCredential(initial_value=None)

Parameters

initial_value
default value: None

Variables

token
str

The authorization token. It can be set by the user at any point in a thread-safe way.

Methods

signed_session

Sign requests session with the token. This method is called every time a request is going on the wire. The user is responsible for updating the token with the preferred tool/SDK. In general there are two options:

  • override this method to update the token in a preferred way and set Authorization header on session

  • not override this method, and have a timer that triggers periodically to update the token on this class

The second option is recommended as it tends to be more performance-friendly.

token

signed_session

Sign requests session with the token. This method is called every time a request is going on the wire. The user is responsible for updating the token with the preferred tool/SDK. In general there are two options:

  • override this method to update the token in a preferred way and set Authorization header on session

  • not override this method, and have a timer that triggers periodically to update the token on this class

The second option is recommended as it tends to be more performance-friendly.

signed_session(session=None)

Parameters

session
<xref:requests.Session>
default value: None

The session to configure for authentication

Return type

<xref:requests.Session>

token

token(new_value)

Parameters

new_value
Required

new value to be set as the token.