MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / revoke_token

Method revoke_token

dwave/cloud/auth/flows.py:244–275  ·  view source on GitHub ↗

Revoke OAuth 2.0 token. Args: token: OAuth 2.0 access or refresh token to be revoked. If refresh token is specified, the authorization server should also revoke the corresponding access tokens. If ``token`` is not specified, then

(self, *,
                     token: Optional[str] = None,
                     token_type_hint: Optional[
                         Literal['access_token', 'refresh_token']] = None
                     )

Source from the content-addressed store, hash-verified

242 return token
243
244 def revoke_token(self, *,
245 token: Optional[str] = None,
246 token_type_hint: Optional[
247 Literal['access_token', 'refresh_token']] = None
248 ) -> bool:
249 """Revoke OAuth 2.0 token.
250
251 Args:
252 token:
253 OAuth 2.0 access or refresh token to be revoked. If refresh token
254 is specified, the authorization server should also revoke the
255 corresponding access tokens. If ``token`` is not specified, then
256 current refresh token is revoked.
257 token_type_hint:
258 Type of the token to be revoked.
259
260 Returns:
261 Token revocation status. True if revocation was successful, or token
262 was invalid already. False in case of an error.
263
264 Note:
265 Token revocation requires that a ``revocation_endpoint`` is defined
266 in :class:`~dwave.cloud.auth.flows.AuthFlow` construction.
267 """
268 if self.revocation_endpoint is None:
269 raise TypeError("Revocation endpoint undefined.")
270
271 response: requests.Response = self.session.revoke_token(
272 url=self.revocation_endpoint, token=token,
273 token_type_hint=token_type_hint)
274
275 return response.ok
276
277 def ensure_active_token(self):
278 if not self.token:

Calls

no outgoing calls