device
oauthlib.oauth2.rfc8628 ~~~~~~~~~~~~~~~~~~~~~~~
This module is an implementation of various logic needed for consuming and providing OAuth 2.0 Device Authorization RFC8628.
DeviceClient
Bases: Client
A public client utilizing the device authorization workflow.
The client can request an access token using a device code and a public client id associated with the device code as defined in RFC8628.
The device authorization grant type can be used to obtain both access tokens and refresh tokens and is intended to be used in a scenario where the device being authorized does not have a user interface that is suitable for performing authentication.
Source code in server/vendor/oauthlib/oauth2/rfc8628/clients/device.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
prepare_request_body(device_code, body='', scope=None, include_client_id=False, **kwargs)
Add device_code to request body
The client makes a request to the token endpoint by adding the device_code as a parameter using the "application/x-www-form-urlencoded" format to the HTTP request body.
:param body: Existing request body (URL encoded string) to embed parameters into. This may contain extra parameters. Default ''. :param scope: The scope of the access request as described by Section 3.3
_.
:param include_client_id: True
to send the client_id
in the body of the upstream request. This is required if the client is not authenticating with the authorization server as described in Section 3.2.1
_. False otherwise (default). :type include_client_id: Boolean
:param kwargs: Extra credentials to include in the token request.
The prepared body will include all provided device_code as well as the grant_type
parameter set to urn:ietf:params:oauth:grant-type:device_code
::
>>> from oauthlib.oauth2 import DeviceClient
>>> client = DeviceClient('your_id', 'your_code')
>>> client.prepare_request_body(scope=['hello', 'world'])
'grant_type=urn:ietf:params:oauth:grant-type:device_code&scope=hello+world'
.. Section 3.2.1
: https://datatracker.ietf.org/doc/html/rfc6749#section-3.2.1 .. Section 3.3
: https://datatracker.ietf.org/doc/html/rfc6749#section-3.3 .. _Section 3.4
: https://datatracker.ietf.org/doc/html/rfc8628#section-3.4
Source code in server/vendor/oauthlib/oauth2/rfc8628/clients/device.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|