Getting “Error: redirect_uri_mismatch” with google_oauth2

后端 未结 5 2008
孤街浪徒
孤街浪徒 2021-02-04 05:04

The URL\'s seem right (Last updated them yesterday):

\"enter

The files too:

<
相关标签:
5条回答
  • 2021-02-04 05:09

    There's a relatively fresh issue with omniauth-oauth2 gem version 1.4 https://github.com/intridea/omniauth-oauth2/issues/81#issuecomment-151038559

    Temporary fix is to downgrade that gem explicitly in the Gemfile

    gem 'omniauth-oauth2', '~> 1.3.1'
    
    0 讨论(0)
  • 2021-02-04 05:14

    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.

    0 讨论(0)
  • 2021-02-04 05:18

    enter image description here

    foo

    vi config/initializers/omniauth.rb OmniAuth.config.full_host = 'https://localhost:3000' Rails.application.config.middleware.use OmniAuth::Builder do provider :google_oauth2, 'google_client_id', 'google_client_secret' end

    0 讨论(0)
  • 2021-02-04 05:33

    I tried all of the above but didn't work for me. In the end noticed in my error message my call back was slightly different. I had a users between localhost:3000 and auth. Not really sure why.

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

    Changed it, waited 30 mins and it worked.

    0 讨论(0)
  • 2021-02-04 05:36

    Sharing a very simple copy-paste solution that worked for me.

    I copied whatever I was specifying in my code as redirectUri i.e. "redirect_uri": "http://127.0.0.1:3001/" and pasted the value of this key inside the Google settings that ask for Authorized redirect URIs. This way I'm ensured that both the parameters are same.

    If the url was computed, I would console.log() it and copy it from the console window before pasting it in for google settings.

    0 讨论(0)
提交回复
热议问题