Device code Grant
- class oauthlib.oauth2.DeviceCodeGrant(request_validator=None, **kwargs)[source]
- add_token(token, token_handler, request)
- Parameters:
token
token_handler – A token handler instance, for example of type oauthlib.oauth2.BearerToken.
request (oauthlib.common.Request) – OAuthlib request.
- create_authorization_response(request: Request, token_handler: Callable) tuple[dict, str, int][source]
Validate the device flow request -> create the access token -> persist the token -> return the token.
- create_token_response(request: Request, token_handler: Callable) tuple[dict, str, int][source]
Return token or error in json format.
- Parameters:
request (oauthlib.common.Request) – OAuthlib request.
token_handler – A token handler instance, for example of type oauthlib.oauth2.BearerToken.
If the access token request is valid and authorized, the authorization server issues an access token and optional refresh token as described in Section 5.1. If the request failed client authentication or is invalid, the authorization server returns an error response as described in Section 5.2. .. Section 5.1: https://tools.ietf.org/html/rfc6749#section-5.1 .. Section 5.2: https://tools.ietf.org/html/rfc6749#section-5.2
- prepare_authorization_response(request, token, headers, body, status)
Place token according to response mode.
Base classes can define a default response mode for their authorization response by overriding the static default_response_mode member.
- Parameters:
request (oauthlib.common.Request) – OAuthlib request.
token
headers
body
status
- validate_grant_type(request)
- Parameters:
request (oauthlib.common.Request) – OAuthlib request.
- validate_scopes(request)
- Parameters:
request (oauthlib.common.Request) – OAuthlib request.
An pseudocode/skeleton example of how the device flow can be implemented is available in the examples folder on GitHub.