3 ,[9> @ s d Z ddlmZmZ ddlZddlZddlZddlmZm Z m Z ddlmZ ddl mZmZmZmZmZmZ ddlmZ dd lmZmZmZ yddlZW n ek r ddljZY nX dd dZdd dZdddZ dddZ!dddZ"dddZ#dd Z$dS ) z oauthlib.oauth2.rfc6749.parameters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module contains methods related to `Section 4`_ of the OAuth 2 RFC. .. _`Section 4`: https://tools.ietf.org/html/rfc6749#section-4 )absolute_importunicode_literalsN)add_params_to_qsadd_params_to_uriunicode_type) scope_changed )InsecureTransportErrorMismatchingStateErrorMissingCodeErrorMissingTokenErrorMissingTokenTypeErrorraise_from_error)OAuth2Token)is_secure_transport list_to_scope scope_to_listc K s t | st d|fd|fg}|r0|jd|f |rF|jdt|f |rX|jd|f x*|D ]"}|| r^|jt||| f q^W t| |S )aa Prepare the authorization grant request URI. The client constructs the request URI by adding the following parameters to the query component of the authorization endpoint URI using the ``application/x-www-form-urlencoded`` format as defined by [`W3C.REC-html401-19991224`_]: :param response_type: To indicate which OAuth 2 grant/flow is required, "code" and "token". :param client_id: The client identifier as described in `Section 2.2`_. :param redirect_uri: The client provided URI to redirect back to after authorization as described in `Section 3.1.2`_. :param scope: The scope of the access request as described by `Section 3.3`_. :param state: An opaque value used by the client to maintain state between the request and callback. The authorization server includes this value when redirecting the user-agent back to the client. The parameter SHOULD be used for preventing cross-site request forgery as described in `Section 10.12`_. :param kwargs: Extra arguments to embed in the grant/authorization URL. An example of an authorization code grant authorization URL: .. code-block:: http GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1 Host: server.example.com .. _`W3C.REC-html401-19991224`: https://tools.ietf.org/html/rfc6749#ref-W3C.REC-html401-19991224 .. _`Section 2.2`: https://tools.ietf.org/html/rfc6749#section-2.2 .. _`Section 3.1.2`: https://tools.ietf.org/html/rfc6749#section-3.1.2 .. _`Section 3.3`: https://tools.ietf.org/html/rfc6749#section-3.3 .. _`section 10.12`: https://tools.ietf.org/html/rfc6749#section-10.12 response_type client_idredirect_uriscopestate)r r appendr r r ) urir r r r r kwargsparamsk r /usr/lib/python3.6/parameters.pyprepare_grant_uri s ' r c K sX d| fg}d|kr"t |d |d<