File: parameters.py

package info (click to toggle)
python-authlib 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,016 kB
  • sloc: python: 26,998; makefile: 53; sh: 14
file content (24 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from authlib.common.urls import add_params_to_qs


def prepare_revoke_token_request(token, token_type_hint=None, body=None, headers=None):
    """Construct request body and headers for revocation endpoint.

    :param token: access_token or refresh_token string.
    :param token_type_hint: Optional, `access_token` or `refresh_token`.
    :param body: current request body.
    :param headers: current request headers.
    :return: tuple of (body, headers)

    https://tools.ietf.org/html/rfc7009#section-2.1
    """
    params = [("token", token)]
    if token_type_hint:
        params.append(("token_type_hint", token_type_hint))

    body = add_params_to_qs(body or "", params)
    if headers is None:
        headers = {}

    headers["Content-Type"] = "application/x-www-form-urlencoded"
    return body, headers