File size: 854 Bytes
5b01a63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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