I am getting {"error":"invalid_client","error_description":"client authentication failed"} 401 response. I did manage to get a user consent (docs: https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.html) by accessing the url manually and logging in to my account using Python 3:
import requests, urllib, base64 my_AppID = "someAppID" my_Ru_Name = "someRuName" scope = "https://api.ebay.com/oauth/api_scope/sell.fulfillment" scope = urllib.parse.quote_plus(scope)
url = f"""https://auth.ebay.com/oauth2/authorize?
client_id={my_AppID}&
redirect_uri={my_Ru_Name}&
response_type=code& scope={scope}&"""
I printed the url string and accessed it in the browser, logged in and "consented". This page said "Authorization successfully completed." so I took the code value from the new redirected page url. After this I was unable to exchange the authorization code for a User access token:
my_CertID = "someCertID" client_id = base64.b64encode(my_AppID.encode())
client_secret = base64.b64encode(my_CertID.encode())
auth_string = "Basic " + client_id.decode() + ":" + client_secret.decode()
consent_code = "v%521.1%25i..................jYw" # from the page's link after logging in consent_code = urllib.parse.quote_plus(code)
headers = {"Content-Type": "application/x-www-form-urlencoded",
"Authorization": auth_string}
data = {"grant_type": "authorization_code", "code": consent_code , "redirect_uri": Ru_Name}
url_token = "https://api.ebay.com/identity/v1/oauth2/token" resp = requests.post(url_token, headers=headers, data=data)
print(resp.text)
# the response I get: {"error":"invalid_client","error_description":"client authentication failed"}
What am I doing wrong? Is it the request part? The encoding?
I am kinda new to all this so thanks in advance!