jackdempsey / omniauth-reddit

20 stars 30 forks source link

OAuth2::Error ... invalid_grant: {"error": "invalid_grant"} #10

Open AdamDenoon opened 8 years ago

AdamDenoon commented 8 years ago

I installed the gem as directed, and placed this into my config/initializers/omniauth.rb file:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :reddit, '[FILTERED APP ID]', '[FILTERED APP SECRET', {:duration => "permanent", :scope => "identity"}
end

It brings me to the page where I can click "allow" on reddit, and sends the state and code to my callback, but immediately crashes with the OAuth::Error:

invalid_grant: {"error": "invalid_grant"}`

Here's a small trace (pertinent to omniauth):

oauth2 (1.2.0) lib/oauth2/client.rb:140:in `get_token'
oauth2 (1.2.0) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
omniauth-oauth2 (1.4.0) lib/omniauth/strategies/oauth2.rb:89:in `build_access_token'
/usr/local/rvm/gems/ruby-2.3.0/bundler/gems/omniauth-reddit-4e54423f2d8a/lib/omniauth/strategies/reddit.rb:35:in `build_access_token'
omniauth-oauth2 (1.4.0) lib/omniauth/strategies/oauth2.rb:73:in `callback_phase'
omniauth (1.3.1) lib/omniauth/strategy.rb:227:in `callback_call'
omniauth (1.3.1) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.3.1) lib/omniauth/builder.rb:63:in `call'
mariusor commented 8 years ago

I had the same issue and it was solved by downgrading the omniauth-oauth2 version to 1.3.1

siegy22 commented 7 years ago

@mariusor You saved my day 💚

wheattcom commented 7 years ago

Unfortunately downgrading now breaks a number of other omni auth providers. Does anybody know if this is an easy fix, or should I just pass on offering reddit for now?

kswope commented 7 years ago

I fixed this with this helpful advice https://github.com/mysmallidea/omniauth-drip/commit/8f8b38e87f9ef758d639fcf25c2ff2176a852c5b

However, I don't want to create a pull request because I have no understanding of omniauth or how the protocol works.