0
votes

I had implemented the code to received authorization code as described in this step:

https://developers.google.com/android-publisher/authorization#generating_a_refresh_token

We deployed this code to one server that has "https://..." domain and this works well. We can get the access_token, refresh_token...

But now we need to deploy the same code to a dev server that has no "https".

I created a new OAuth client id with redirect uri using the dev server (no https, the rest /api/v1/... is the same as the previous working server)

Now anytime I tried to go to this url and Allow access

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://dev_server/api/v1/...&client_id=dev_server_client_id

I got 401 Unauthorized.

I'm not sure why, but the only difference I can see is "https" vs "http".

Any idea why? Thank you very much.

1
What does the redirect uri you put in Google Dev console for production and dev look like? I dont think the problem is with the httpsDaImTo
Thank you @DaImTo. The values in my console are correct but I forgot to update the values in my .env fileHoang Trinh

1 Answers

1
votes

Actually I forgot to update the corresponding values in my code

const oauth2Client = new OAuth2(
    config.googleApi.clientId,
    config.googleApi.clientSecret,
    config.googleApi.redirectUri // <= Especially this value
);

These values need to be updated to (beside values on google console).