Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Generate Access Token operation is failing on making ajax call to proxy even though auth code is getting generated succefully

Not applicable

I am making a call from postman to the same proxy and i am able to generate access token but when making a similar call using ajax with same client id and secret ... I am bale to generate the auth code but access token generation is failing giving me error {"ErrorCode" : "invalid_client", "Error" :"ClientId is Invalid"}.

THe request is same in both the cases but is working fine with postman but not with ajax.

0 3 457
3 REPLIES 3

davissean
Former Googler

Please could you post the Ajax request you are making, including any headers?

If you are using the Auth Code grant type, and the API is compliant with the specifications then your request should look like this:

https://tools.ietf.org/html/rfc6749#section-4.1.3

In that case, it is likely that the client_id is invalid or missing.

I am sending Content-type as "application/json" in both the cases but its working when request is send from postman but not with ajax. client id is correct and is same for both forms of request.

POST /api/v2/oauth/accesstokens

Content-Type application/json

{"clientId":"******","clientSecret":"******"}

Thats my sample request in both the cases from postman and ajax

In both the cases auth code is getting generated successfully but in case of ajax call generate access token is failing