5

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?

asked Jun 20, 2017 at 9:37
3
  • Addition: my files has python2 strings - not unicode. I've also tried switching to unicode - it didn't help Commented Jun 20, 2017 at 9:39
  • Have you tried passing the data dict as a json formatted str? E.g. after import json data=json.dumps(data) Commented Jun 20, 2017 at 15:44
  • It looks like the ebay link is a dead link now and I'm having trouble getting the oauth process to work. What is the "auth code" above meant to be? Commented Dec 26, 2021 at 17:47

1 Answer 1

4

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

answered Jun 22, 2017 at 3:58
Sign up to request clarification or add additional context in comments.

1 Comment

You are legend mate. Spent an hour figuring why sandbox wasa working and prod not. This should be somewhere on their documentation. Thumbs Up

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.