1
votes

I am trying to get access_token using the instructions here developers.google.com/accounts/docs/OAuth2InstalledApp (which I have followed very diligently) but keep hitting the redirect_uri_mismatch error. What am I doing wrong?

First I create a installed app/other using the console (

Client ID for native application

Client ID ... Client secret ... Redirect URIs

    urn:ietf:wg:oauth:2.0:oob
    local host url

Got the authorization code successfully using the browser using

https:// accounts.google.com/o/oauth2/auth?client_id=818722811109-8ak0a1l3ooqqt3bd97bktr33ghenlptk.apps.googleusercontent.com&redirect_uri=http://:51551/Callback&response_type=code&scope=https://www.googleapis.com/auth/adexchange.seller.readonly&access_type=offline

curl -d "code=...&client_id=...&client_secret=...&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob" -X POST https:// accounts.google.com/o/oauth2/token

gives me error "redirect_uri_mismatch"

I'm at a loss what I am doing wrong. I use the redirect_uri from the console which is for the non-domain one, but can't get past this error.

Any pointers would be appreciated.

Thanks.

2

2 Answers

-1
votes

Sorry the problem is not in code. stackoverflow does not allow localhost in urls, hence I had to delete that domain to get the post to go through. The code works fine after clicking the accept button I do see the code= in the redirect url in localhost.

The problem is in the curl POST.