Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python请求获取易趣访问令牌(交换身份验证令牌)_Python_Python 2.7_Oauth 2.0_Python Requests_Ebay Api - Fatal编程技术网

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

使用python请求获取易趣访问令牌(交换身份验证令牌),python,python-2.7,oauth-2.0,python-requests,ebay-api,Python,Python 2.7,Oauth 2.0,Python Requests,Ebay Api,我正在尝试使用以获取访问令牌 这是我的主要文件: 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-urlenco

我正在尝试使用以获取访问令牌

这是我的主要文件:

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,
)
但是我在
r.json()
中得到的只是:

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

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

对不起,我够蠢了,我没有在易趣上看到勾选框。

另外:我的文件有python2字符串,而不是unicode。我也尝试过切换到unicode,但没有用。您是否尝试过将数据dict作为json格式的str传递?例如,
import json
data=json.dumps(data)
之后,您就是传奇伴侣。花了一个小时思考为什么沙盒是一个有效的产品而不是一个。这应该在他们的文档中的某个地方。竖起大拇指
{u'error_description': u'request is missing a required parameter or malformed.', u'error': u'invalid_request'}