Getting eBay Access Token (Exchanging auth token)

2019-07-13 11:31发布

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

Here is my main file:

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,
)

Here's the make_basic_auth_header() function:

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

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?

1条回答
做个烂人
2楼-- · 2019-07-13 12:08

sorry, I was stupid enough and I didn't see the tickbox on ebay.here's the tickbox, after I've clicked it

查看更多
登录 后发表回答