Ejemplo n.º 1
0
def get_pocket_access_token(access_token_uri, consumer_key, code):
    headers = {
        'Content-Type': 'application/json; charset=UTF-8',
        'X-Accept': 'application/json',
    }
    payload = {
        'consumer_key': consumer_key,
        'code': code,
    }
    resp, content = pocket.http_request(
        access_token_uri,
        headers=headers,
        data=json.dumps(payload),
        method='POST',
    )
    return OAuthResponse(resp, content)
Ejemplo n.º 2
0
def get_pocket_request_code(request_token_uri, consumer_key, redirect_uri, state=None):
    headers = {
        'Content-Type': 'application/json; charset=UTF-8',
        'X-Accept': 'application/json',
    }
    payload = {
        'consumer_key': consumer_key,
        'redirect_uri': redirect_uri,
    }
    if state:
        payload['state'] = state

    resp, content = pocket.http_request(
        request_token_uri,
        headers=headers,
        data=json.dumps(payload),
        method='POST',
    )
    return OAuthResponse(resp, content)