使用 python 请求获取 eBay 访问令牌(交换身份验证令牌) [英] Getting eBay Access Token (Exchanging auth token) with python requests

查看:40
本文介绍了使用 python 请求获取 eBay 访问令牌(交换身份验证令牌)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 本指南获取访问令牌.

I'm trying to use this guide to get access token.

这是我的主文件:

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() 中得到的只是:

But all I get in r.json() is:

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

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

I'm frustrated - what am I doing wrong?

推荐答案

抱歉,我太笨了,没有在 ebay 上看到勾选框.

sorry, I was stupid enough and I didn't see the tickbox on ebay.

这篇关于使用 python 请求获取 eBay 访问令牌(交换身份验证令牌)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆