Reputation: 41
I unable to authorize my rails app with bigcommerce oauth in staging/production server. The same configuration/code is working in development using ngrok.
Error message received: (bigcommerce) Authentication failure! invalid_credentials: OAuth2::Error, redirect_uri_mismatch: Parameter redirect_uri does not match registered URI {"error":"redirect_uri_mismatch","error_description":"Parameter redirect_uri does not match registered URI"}
This is what the app send to bigcommerce login server:
Then Bigcommerce call app callback:
I'm pretty sure redirect_uri passed to login server is same with the one i entered in my app callback url (copy paste).
Gem used: gem 'devise', '~> 2.2.4' gem 'omniauth-bigcommerce' gem 'bigcommerce', :github => 'mechatama/bigcommerce-api-ruby', :branch => 'oauth'
Am I missing something? I've been searching for a solution for the last few days.
Upvotes: 4
Views: 1024
Reputation: 1
You need to add environment based redirect uri on your devise.rb
example :
setup: (lambda do |env|
request = Rack::Request.new(env)
env['omniauth.strategy'].options['token_params'] = {:redirect_uri => 'http://localhost:81/users/auth/google_oauth2/callback'}
# http://e3a098b5.ngrok.io/users/auth/google_oauth2/callback
end
Upvotes: 0