3

I had try as this answer Can the redirect_uri contain port number?

But I also get the redirect_uri does not match the redirect_uri error.

Provided `redirect_uri` does not match the `redirect_uri` this code was created with

::1 - - [14/Mar/2019:22:49:31 CST] "GET /auth/stackexchange/callback?code=umZowLeAHg*z6Gs*(yIBUg))&state=7a24d06c83edd66415483ce0b32d1bd8714b730215a30e9c HTTP/1.1" 302 9http://localhost:3000/ -> /auth/stackexchange/callback?code=umZowLeAHg*z6Gs(yIBUg))&state=7a24d06c83edd66415483ce0b32d1bd8714b730215a30e9c

Started GET "/auth/failure?message=invalid_credentials&origin=http%3A%2F%2Flocalhost%3A3000%2Fusers%2Fabbc%2Fedit&strategy=stackexchange" for ::1 at 2019-03-14 22:49:50 +0800

::1 - - [14/Mar/2019:22:49:50 CST] "GET /auth/failure?message=invalid_credentials&origin=http%3A%2F%2Flocalhost%3A3000%2Fusers%2Fabbc%2Fedit&strategy=stackexchange HTTP/1.1" 301 88http://localhost:3000/ -> /auth/failuremessage=invalid_credentials&origin=http%3A%2F%2Flocalhost%3A3000%2Fusers%2Fabbc%2Fedit&strategy=stackexchange

I used Rails and my codes like this:

gem 'omniauth', '~> 1.9'
gem 'omniauth-oauth2', '~> 1.6'
gem 'omniauth-stackexchange', '~> 0.2.1'

# initializers/omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :stackexchange, Rails.application.secrets.stack_client_id, Rails.application.secrets.stack_client_secret, public_key: Rails.application.secrets.stack_key, site: 'stackoverflow',callback_url:'http://localhost:3000/'
end

My stackapp settings like this:

OAuth Domain:

localhost

Application Website:

http://localhost:3000/

Stack Apps Post: Not set

Client Side Flow Is Disabled

Desktop OAuth Redirect Uri Is Disabled

These are the setting pictures:

enter image description here

enter image description here

Who can help me ? Thanks so much.

  • I'm not a Ruby expert, but that doesn't look like how others use omniauth-stackexchange. See this other Q&A for example. – Brock Adams Mar 14 at 19:11
0

I get the reason:

Do not use gem 'omniauth-stackexchange', '~> 0.2.1' ,but instead of gem 'omniauth-stackexchange', git: 'https://github.com/nashby/omniauth-stackexchange.git'

The reason see this:add call back url

New contributor
sylor_huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .