Question

Unable to generate API Token from Client ID/Secret

  • 8 November 2019
  • 7 replies
  • 1702 views

I’m having a bit of trouble getting started with the API. I’m trying a token via OAuth2 and have tried from the terminal on my Mac and from the RESTClient add-on in Firefox. I’ve generated keys in production and our sandbox and no matter what I’ve tried, I get the same response:

 

{"error_description":"Invalid client authentication","error":"invalid_client"}

 

Example code from the API Docs that I’m also using from my MAC

curl -X POST https://api2-us-west-2.insided.com/oauth2/token
-H 'Content-Type: application/x-www-form-urlencoded'
-d 'grant_type=client_credentials'
-d 'client_id=<myID>'
-d 'client_secret=<mySecret>'
-d 'scope=read'

I’m sure I’m missing something simple, but I’m hopeful someone can give me some pointers.


7 replies

Hey @Drew C. 

From first glance the request appears to have the correct structure and format.

However the error suggests that there may have been a typo in the ‘client_id’ or ‘secret’ values. We tried requesting a token using the same request structure (but with our own client_id + secret) and it appeared to work. 

Once we modified the client_id and secret (removing/adding characters), we get the same error. Can you confirm there were no accidental characters added/removed to either client_id or secret?

Unfortunately we cannot check the correct secret value since it will be unknown to us. The correct client_id should be listed in the Control environment however.

As a follow-up question: I noticed you mentioned that you generated keys for production and sandbox environments.

Does the sandbox environment refer to our staging environment?

If so: the credentials for that environment cannot be used with the production hostname. If you generated credentials for the InSided staging environment, you will have to use a different hostname when trying to request tokens.

If the sandbox environment refers to something on your side then you can ignore this post.

Hi @rik.insided,

Sandbox = staging :slight_smile:   Sorry for any confusion

I’m quite confident there are no typos in the ID or secret - they were copy/pasted from the page (after a bit of a hack to get them to actually copy).

I wondered if I was somehow using the wrong API server since it does seem that my credentials didn’t exist on the one I used. Maybe you can check and PM me the correct ones for staging vs prod in our community?

Thanks,

-Drew

@Drew C.

No need to apologise :slight_smile:

I was suspecting that the issue may have been that staging credentials were used with our production API. In that case the production API would indeed complain that those credentials were invalid.

FYI: the correct staging API hostname is https://api2-eu-west-1.almostinsided.com.

I will check which credentials you generated for the staging and production environments respectively and follow up with a PM.

PS. I heard about the ‘hack’ that was necessary, we will be fixing that issue. We will also work on showing the correct hostname on the page where you generate the credentials to avoid this sort of confusion in the future :slight_smile:

Hi, I encounter the same problem as @Drew C. described.

How can I know to which API endpoint should I call? @rik.insided said that you will work on showing the correct hostname on the page where you generate the credentials to avoid this sort of confusion but I don’t see it.

 

I’m getting the same error - “{"error_description":"Invalid client authentication","error":"invalid_client"}”

Badge

@aviv_tonk  Took me a bit to track this down initially as well, found this article:

 

Documentation

You can find our API documentation here:

 

Hope that’s helpful, if so, that page should probably be linked to from the API documentation

Just had the same issue. I forgot that the URL for staging is almostinsided.com, whereas production is just insided.com :)

 

Reply