

def prepare_grant_uri(uri, client_id, response_type, redirect_uri=None, scope=None, state=None, **kwargs):
    'Prepare the authorization grant request URI.\n\n    The client constructs the request URI by adding the following\n    parameters to the query component of the authorization endpoint URI\n    using the ``application/x-www-form-urlencoded`` format as defined by\n    [`W3C.REC-html401-19991224`_]:\n\n    :param response_type: To indicate which OAuth 2 grant/flow is required,\n                          "code" and "token".\n    :param client_id: The client identifier as described in `Section 2.2`_.\n    :param redirect_uri: The client provided URI to redirect back to after\n                         authorization as described in `Section 3.1.2`_.\n    :param scope: The scope of the access request as described by\n                  `Section 3.3`_.\n\n    :param state: An opaque value used by the client to maintain\n                  state between the request and callback.  The authorization\n                  server includes this value when redirecting the user-agent\n                  back to the client.  The parameter SHOULD be used for\n                  preventing cross-site request forgery as described in\n                  `Section 10.12`_.\n    :param kwargs: Extra arguments to embed in the grant/authorization URL.\n\n    An example of an authorization code grant authorization URL:\n\n    .. code-block:: http\n\n        GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz\n            &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1\n        Host: server.example.com\n\n    .. _`W3C.REC-html401-19991224`: http://tools.ietf.org/html/rfc6749#ref-W3C.REC-html401-19991224\n    .. _`Section 2.2`: http://tools.ietf.org/html/rfc6749#section-2.2\n    .. _`Section 3.1.2`: http://tools.ietf.org/html/rfc6749#section-3.1.2\n    .. _`Section 3.3`: http://tools.ietf.org/html/rfc6749#section-3.3\n    .. _`section 10.12`: http://tools.ietf.org/html/rfc6749#section-10.12\n    '
    if (not is_secure_transport(uri)):
        raise InsecureTransportError()
    params = [('response_type', response_type), ('client_id', client_id)]
    if redirect_uri:
        params.append(('redirect_uri', redirect_uri))
    if scope:
        params.append(('scope', list_to_scope(scope)))
    if state:
        params.append(('state', state))
    for k in kwargs:
        if kwargs[k]:
            params.append((unicode_type(k), kwargs[k]))
    return add_params_to_uri(uri, params)

dataset/ETHPy150Open idan/oauthlib/oauthlib/oauth2/rfc6749/parameters.py prepare_grant_uri/original