Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Redirect URI doesn't match original redirect URI" error #23

Open
ozgun opened this issue Nov 27, 2015 · 6 comments
Open

"Redirect URI doesn't match original redirect URI" error #23

ozgun opened this issue Nov 27, 2015 · 6 comments

Comments

@ozgun
Copy link

ozgun commented Nov 27, 2015

Hi,

I've set up an Instagram app/client and Valid redirect URIs for my instagram app is like the following:

http://127.0.0.1.xip.io:3000/dashboard/omni/auth/instagram/callback

I've started to get Redirect URI doesn't match original redirect URI error.

Here is the backtrace:

I, [2015-11-27T13:34:10.883170 #10189]  INFO -- omniauth: (instagram) Callback phase initiated.
[httplog] Connecting: api.instagram.com:443
[httplog] Sending: POST http://api.instagram.com:443/oauth/access_token
[httplog] Data: client_id=11111&client_secret=22222&code=XXXXX&grant_type=authorization_code&redirect_uri=http://127.0.0.1.xip.io:3000/dashboard/omni/auth/instagram/callback?code=XXXXX&state=33333
[httplog] Status: 400
[httplog] Benchmark: 0.20239810000020952 seconds
[httplog] Response:
{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI doesn't match original redirect URI"}
E, [2015-11-27T13:34:11.487103 #10189] ERROR -- omniauth: (instagram) Authentication failure! invalid_credentials: OAuth2::Error, : 
{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI doesn't match original redirect URI"}

After digging around, I've noticed that if I remove query string from redirect_uri which is ?code=XXXXX&state=33333, it works like a charm. However, according to Instagram API Documentation(http://instagram.com/developer/authentication/) it is possible to use query parameters.

In order to remove query string from redirect_uri, I had to add the following method to omniauth-instagram-1.0.1/lib/omniauth/strategies/instagram.rb file:

def query_string
  ''
end

But, I'm not sure if this is the best solution. Is this a bug or is there a problem with my settings? This gem used to work before.

Thanks.

-Ozgun.

@AlxGolubev
Copy link

Have the same problem. Any solutions?

@AlxGolubev
Copy link

@ozgun I found solution.
Just install gem from GitHub repo

gem 'omniauth-instagram', github: 'ropiku/omniauth-instagram'

Also, you can check my configuration.
Alt text

@ozgun
Copy link
Author

ozgun commented Nov 28, 2015

Hi Alex,

Thanks for your suggestion.

My workaround was to create an initializer as below:

OmniAuth::Strategies::Instagram.class_eval do
    def query_string
    ''
  end
end

@anggainwgs
Copy link

Hi all,
I have same problem,
Client Status: Sandbox Mode,
and I end up with:
{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI does not match registered redirect URI"}
should we need another status?
Thanks before.

@cmcollin41
Copy link

@AlxGolubev you're a legend. Thank you for sharing that.

@Tejaram-viva
Copy link

Hello All,
I have same error when i try to login with Instagram in my Angular-5 Project
please help
"

error_type "OAuthException"
code 400
error_message "Redirect URI does not match registered redirect URI"

"
my Redirect URI is : http://localhost:4200/profile

Thanks in Advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants