Вопрос

With the open source project google-api-ruby-client, I'm trying to run the OAuth 2.0 sample calendar.rb, which will access Google Calendar API. I've created client ID in Google API console, and fill the client ID and the secret in the ruby script.

However, after I run the ruby script

ruby calendar.rb

and then open http://localhost:4567, the browser return error information from Google to me:

Error: redirect_uri_mismatch
The redirect URI in the request: http://localhost:4567/oauth2callback did not match a     registered redirect URI

I checked the information in the Google API console:

Redirect URIs:  https://localhost/oauth2callback
JavaScript origins: https://localhost

What's the problem and how to solve it? Thanks in advance.

Это было полезно?

Решение

The redirect URI has to match exactly. You can't omit anything. You've dropped the port number. But mismatching a trailing slash or really anything else will cause this error. It has to be an exact, character-for-character match.

The two values should be:

Redirect URIs: https://localhost:4567/oauth2callback

JavaScript origins: https://localhost:4567

Другие советы

I didn't have the port numbers and it worked fine.

However, the Redirect URI was: http://localhost/oauth2callback

I had this example working last night.

I faced the same problem. Everything was matching, URL was correct, consent page was filled, but I had to generate a new Client ID three times. It started working just on the third time. I don't know the reason. I didn't change anything in configuration or code, it just started working with the third Client ID and Client Secret.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top