Redirect_Uri_Mismatch. Login with Google Using Ruby on Rails

redirect_uri_mismatch. Login with Google using Ruby on Rails

Try to downgrade the gem (could be compatibility problem) :

gem 'omniauth-oauth2', '~> 1.3.1'

Getting Error: redirect_uri_mismatch with google_oauth2

It looks like the request is hitting http://localhost:3000/auth/google_oauth2/callback, but your specified redirect URI matching the similar pattern is for https. Adding http://localhost:3000/auth/google_oauth2/callback to your list of redirects may potentially solve that issue.

EDIT: Another potential fix is including a trailing / in the corresponding redirect URIs, which appeared to work in this case.

redirect_uri_mismatch with OmniAuth Google oauth2 on Heroku

I figured out what the problem was. On the google developer console for my app, on
OAuth 2.0 Client IDs, I had created an ID with type "Other" instead of "Web application".

Creating a new one on https://console.cloud.google.com/apis/credentials?project=myproject with the type "Web application" and adding the callback url (both http and https) to Authorized redirect URIs solved the problem.

Sample Image

Error: redirect_uri_mismatch when using omniauth-google-oauth2

In console.developers.google.com. Enter your app’s URL plus

“/auth/google_oauth2/callback” 

in “Authorized redirect URIs field. So It should be:

http://localhost:3000/auth/google_oauth2/callback

Google OAuth 2.0 and Devise - error : redirect_uri_mismatch

Allright, finally found out what was the problem...

The 'omniauth-google-oauth2'gem only works with version 1.3.1 of the 'omniauth-oauth2' gem.

So I changed my Gemfile like this:

# Social Networks Authentification
gem 'omniauth-oauth2', '~> 1.3.1' # Don't touch that unless you don't want Google omniauth to work!
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-linkedin'
gem 'omniauth-google-oauth2' # Works only with omniauth-oauth2 v 1.3.1

And now everything works fine!

See this thread for more details.

Authorization Error, Error 400: redirect_uri_mismatch Gmail API

There are several types of auth lets look at two of them. The first being web which would be designed to work on a web server where the authorization is returned to the webservier itself to handle it. The second being an installed application which would return the response to local host or the endpoint which sent the reuqest.

The code you are following Ruby quick start states at the top that it is designed to work as a console application or installed app which is why you are seeing urn:ietf:wg:oauth:2.0:oob,that means localhost

Complete the steps described in the rest of this page to create a simple Ruby command-line application that makes requests to the Gmail API.

THe code used to authenticate with the two different types of clients is different. the code in your example is designed to work with an installed application there for for it to work you need to create installed native credentials on google developer console you have created web credentials which will not work with the code you are using.

for a web server application you should be following webauth

require 'google/apis/drive_v2'
require 'google/api_client/client_secrets'

client_secrets = Google::APIClient::ClientSecrets.load
auth_client = client_secrets.to_authorization
auth_client.update!(
:scope => 'https://www.googleapis.com/auth/drive.metadata.readonly',
:redirect_uri => 'http://www.example.com/oauth2callback',
:additional_parameters => {
"access_type" => "offline", # offline access
"include_granted_scopes" => "true" # incremental auth
}
)


Related Topics



Leave a reply



Submit