o ‘¸õa&ã@s\dZddlmZmZddlmZddlmZddlm Z m Z ddl m Z Gdd„deƒZ d S) z¯ oauthlib.oauth2.rfc8628 ~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of various logic needed for consuming and providing OAuth 2.0 Device Authorization RFC8628. é)ÚBackendApplicationClientÚClient)ÚInsecureTransportError)Úprepare_token_request)Úis_secure_transportÚ list_to_scope)Úadd_params_to_urics<eZdZdZdZ‡fdd„Zd dd„Z  d d d „Z‡ZS)Ú DeviceClientaâ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. z,urn:ietf:params:oauth:grant-type:device_codec s$tƒj|fi|¤Ž| d¡|_dS)NÚ client_secret)ÚsuperÚ__init__Úgetr )ÚselfÚ client_idÚkwargs©Ú __class__©úH/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc8628/clients/device.pyr szDeviceClient.__init__NcKs–t|ƒstƒ‚|dur|jn|}d|jfd|jfg}|jdur'| d|jf¡|r2| dt|ƒf¡|D]}||rE| t|ƒ||f¡q4t ||ƒS)NrÚ grant_typer Úscope) rrrrrr ÚappendrÚstrr)rÚurirrÚparamsÚkrrrÚprepare_request_uri$s € z DeviceClient.prepare_request_uriÚFcKs>|j|d<||d<|dur|jn|}t|jf|||dœ|¤ŽS)aAdd 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 paramters. 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.4`: https://datatracker.ietf.org/doc/html/rfc8628#section-3.4 rÚinclude_client_idN)ÚbodyÚ device_coder)rrrr)rr rrrrrrrÚprepare_request_body7s # ÿÿz!DeviceClient.prepare_request_body)N)rNF) Ú__name__Ú __module__Ú __qualname__Ú__doc__rr rr!Ú __classcell__rrrrr s  ÿr N)r%Úoauthlib.oauth2rrÚoauthlib.oauth2.rfc6749.errorsrÚ"oauthlib.oauth2.rfc6749.parametersrÚoauthlib.oauth2.rfc6749.utilsrrÚoauthlib.commonrr rrrrÚs