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


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][2]][2]

[![enter image description here][3]][3]

Who can help me ? Thanks so much.


  [1]: https://stackapps.com/questions/4596/can-the-redirect-uri-contain-port-number/7852#7852
  [2]: https://i.sstatic.net/rwqy7.png
  [3]: https://i.sstatic.net/9RykC.png