question

duracelldirectuk avatar image
0 Likes"
duracelldirectuk asked ·

getPrivileges help with request header

I'm using the getPrivileges (Account API) to retrieve the account's seller limit.


I'm referring to the documentation here: https://developer.ebay.com/api-docs/sell/account/resources/privilege/methods/getPrivileges


It says it only required one header, "All requests made to eBay REST operations require you to provide the Authorization HTTP header for authentication authorization. This method has no additional required header"


I had a quick read in this documentation about how to make a call:

https://developer.ebay.com/api-docs/static/make-a-call.html

And it says for Authorization header format should be like this "

HTTP headers:    Authorization = Bearer <Your-Application-token-value>


So essentially in java i've only added the authorization header to the httpRequest and supplied the authentication token. Like this:

HttpPost httpRequest = new HttpPost("https://api.ebay.com/sell/account/v1/privilege/";);

httpRequest.addHeader("Authorization", "Bearer " + [AUTH_TOKEN_HERE]);


But keep getting this error:

ebayResponseData: {

"errors" : [ {

"errorId" : 1001,

"domain" : "OAuth",

"category" : "REQUEST",

"message" : "Invalid access token",

"longMessage" : "Invalid access token. Check the value of the Authorization HTTP request header."

} ]

}

account api
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
gblohm_de avatar image
0 Likes"
gblohm_de answered ·

Are you sure you've refreshed your token recently? User access tokens are limited to two hours, which is very little when you're debugging code, so it might just be an outdated token .


I'm using the java.net classes (you seem to be using the apache classes when you're using HttpPost); the following code works for me:


URL url = new URL(completeURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("HEAD");
conn.addRequestProperty("Authorization", "Bearer "+token.accessToken);
logger.debug("Using Authorization: Bearer "+token.accessToken);
conn.connect();
int result = conn.getResponseCode();
logger.debug("Result code is "+result);


where completeURL is something like


https://apiz.sandbox.ebay.com/sell/finances/v1/transaction_summary?filter=transactionStatus:%7BPAYOUT%7D


and token.accessToken is what the Auth API returned in the access_token JSON field.


However, when my token expires, I get a 401 and the exact payload that you got.



Also, when you requested the initial auth code and user token, did you add the scope that you need for your API?


· 1 · Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Oh I see I'm using the incorrect token mistook this for the Auth'n'Auth token. How do i go about to generate the OAuth token?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.