bhushankummar / eBay-node-client

Ebay NodeJS Wrapper
MIT License
55 stars 66 forks source link

Invalid access token. Check the value of the Authorization HTTP request heade #13

Closed ineffablep closed 5 years ago

ineffablep commented 5 years ago

Hi, I have generated User Token from eBay Sandbox and set it to eBay.setToken(EBAY_TOKEN);

But getting Invalid access token. Check the value of the Authorization HTTP request header. Do I need to mention anything else

bhushankummar commented 5 years ago

@ineffablep For a sandbox, it's necessary to set an environment variable. Please check here https://github.com/bhushankumarl/eBay-node-client#to-enable-sandbox-purpose.

tohfaakib commented 5 years ago

"Invalid access token. Check the value of the Authorization HTTP request header" I am having this error. Please see the screenshot. https://drive.google.com/open?id=13ABBdQ23vpuZlyk8bdrhnwow0-yLa-G0 Please suggest me what to do.

kaelscion commented 5 years ago

Did you go through the configuration steps to generate your Oauth Token or Client ID Token?

Because utils.USER_TOKEN just pulls your valid OAuth Token from the USER_TOKEN environment variable. If you haven't created an OAuth token that is valid for that scope (part of eBay your trying to access), you will get the Invalid ID error.

Also, if you scroll up that error a bit, there should be a string in there somewhere that tells you why the token was invalid. Usually it will say something like "not valid for this scope" or "was issued to another client" etc.

tohfaakib commented 5 years ago

I have generated token from here, "https://developer.ebay.com/my/keys". but then what to do with the token. I really don't know.

tohfaakib commented 5 years ago

I am not seeing anything like this, "not valid for this scope" or "was issued to another client".

kaelscion commented 5 years ago

I had a real tough time getting all of this to work at first too so don't sweat it too much :D.

First thing I would do, is a console.log to see if the USER_TOKEN env variable even has a value. Comment out everything after utils.USER_TOKEN line. Then, on the line directly after that one (from your screenshot it would be line 12), do a console.log(utils.USER_TOKEN) call (uncommented) and see what the output is. If you get an empty string or null (blank output), then you know that your token is invalid because you are asking ebay to use a token that == '' or nothing at all.

tohfaakib commented 5 years ago

I did that. and the token is "undefined". Sir, can please tell me how to fix that?

tohfaakib commented 5 years ago

capture

kaelscion commented 5 years ago

okay, so that means that your USER_TOKEN environment variable is not set. To remedy this, simply type utils.USER_TOKEN=<unquoted_OAuth_token>, replacing the bracketed text with your ebay OAuth token, the line before var userToken = utils.USER_TOKEN.

Just be sure that if you are using source control (like git, mercurial, etc) or are going to post the finished project somewhere, that you find a different way to store your environment variables. If this is just for personal use, leaving your token in your project file should be fine as long as you are not hosting your project on GitHub, BitBucket, or any other code sharing site.

tohfaakib commented 5 years ago

capture Like this? It is saying "Access Denied".

tohfaakib commented 5 years ago

yes, if it just works then okay. I need it to work.

kaelscion commented 5 years ago

scroll up and another screenshot please?

kaelscion commented 5 years ago

also, remove that photo ASAP as it has your eBay auth key in it and you dont want anybody else to be able to see that.

tohfaakib commented 5 years ago

and in eBay token page, it is saying, this token is valid for just a few seconds.

tohfaakib commented 5 years ago

capture

kaelscion commented 5 years ago

have you taken a look at the samples for getting a proper OAuth token here:

https://github.com/bhushankumarl/eBay-node-client/blob/master/examples/javaScript/application/oauthToken.js

as of yet?

tohfaakib commented 5 years ago

capture

It is saying "Invalid client".

kaelscion commented 5 years ago

what scope are you trying to access on eBay?

tohfaakib commented 5 years ago

capture now access token is printing here.

kaelscion commented 5 years ago

That's because, on line 15, you're asking it to by entering console.log('token.access_token', token.access_token)

tohfaakib commented 5 years ago

yes. now, how can I get that token in the main program and make it work?

tohfaakib commented 5 years ago

capture now I am getting token from 'oAuth.js' directly but it is showing "Access Denied".