使用python请求获取eBay访问令牌(交换身份验证令牌)

时间:2017-06-20 09:37:59

标签: python python-2.7 oauth-2.0 python-requests ebay-api

我正在尝试使用this guide来获取访问令牌。

这是我的主要文件:

import requests

from utils import make_basic_auth_header, conf
code = '<Auth code here>'
url = "%s/identity/v1/oauth2/token" % conf('EBAY_API_PREFIX')
headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': make_basic_auth_header()
    }

data = {
    'grant_type': 'authorization_code',
    # 'grant_type': 'refresh_token',
    'state': None,
    'code': code,
    'redirect_uri': conf('EBAY_RUNAME')
}
r = requests.post(
    url,
    data=data,
    headers=headers,
)

这是make_basic_auth_header()函数:

def make_basic_auth_header():
    auth_header_payload = '%s:%s' % (conf('EBAY_APP_ID'), conf('EBAY_CERT_ID'))
    auth_header_base64 = base64.b64encode(auth_header_payload)
    auth_header = 'Basic %s' % auth_header_base64
    return auth_header

但我进入r.json()的所有内容都是:

{u'error_description': u'request is missing a required parameter or malformed.', u'error': u'invalid_request'}

我很沮丧 - 我做错了什么?

1 个答案:

答案 0 :(得分:2)

抱歉,我太傻了,我在ebay上看不到复选框。here's the tickbox, after I've clicked it

相关问题