Prepare the access token request. Per `Section 4.1.3`_. The client makes a request to the token endpoint by adding the following parameters using the ``application/x-www-form-urlencoded`` format in the HTTP request entity-body: :param grant_type: To indicate grant type being used,
(grant_type, body="", redirect_uri=None, **kwargs)
| 67 | |
| 68 | |
| 69 | def prepare_token_request(grant_type, body="", redirect_uri=None, **kwargs): |
| 70 | """Prepare the access token request. Per `Section 4.1.3`_. |
| 71 | |
| 72 | The client makes a request to the token endpoint by adding the |
| 73 | following parameters using the ``application/x-www-form-urlencoded`` |
| 74 | format in the HTTP request entity-body: |
| 75 | |
| 76 | :param grant_type: To indicate grant type being used, i.e. "password", |
| 77 | "authorization_code" or "client_credentials". |
| 78 | :param body: Existing request body to embed parameters in. |
| 79 | :param redirect_uri: If the "redirect_uri" parameter was included in the |
| 80 | authorization request as described in |
| 81 | `Section 4.1.1`_, and their values MUST be identical. |
| 82 | :param kwargs: Extra arguments to embed in the request body. |
| 83 | |
| 84 | An example of an authorization code token request body:: |
| 85 | |
| 86 | grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA |
| 87 | &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb |
| 88 | |
| 89 | .. _`Section 4.1.1`: https://tools.ietf.org/html/rfc6749#section-4.1.1 |
| 90 | .. _`Section 4.1.3`: https://tools.ietf.org/html/rfc6749#section-4.1.3 |
| 91 | """ |
| 92 | params = [("grant_type", grant_type)] |
| 93 | |
| 94 | if redirect_uri: |
| 95 | params.append(("redirect_uri", redirect_uri)) |
| 96 | |
| 97 | if "scope" in kwargs: |
| 98 | kwargs["scope"] = list_to_scope(kwargs["scope"]) |
| 99 | |
| 100 | if grant_type == "authorization_code" and kwargs.get("code") is None: |
| 101 | raise MissingCodeException() |
| 102 | |
| 103 | for k in kwargs: |
| 104 | if kwargs[k]: |
| 105 | params.append((to_unicode(k), kwargs[k])) |
| 106 | |
| 107 | return add_params_to_qs(body, params) |
| 108 | |
| 109 | |
| 110 | def parse_authorization_code_response(uri, state=None): |
no test coverage detected
searching dependent graphs…