jaegernoms jaegernoms - 1 year ago 111
Ruby Question

invalid_grant error using omniauth-reddit in rails

I'm trying to use the omniauth-reddit gem. I have gotten as far as getting the account holder to say they want to "allow" my app to grant access to their account. After I click allow, I get an error from Rails:

invalid_grant: {"error": "invalid_grant"}

This is what my omniauth.rb file looks like:

Rails.application.config.middleware.use OmniAuth::Builder do
provider :reddit, "XXX", "YYY", {:duration => "permanent", :scope => "identity,subscribe,vote,submit,history,read,mysubreddits"}

And my routes:

Rails.application.routes.draw do
root 'homes#index'

get '/auth/reddit', as: :reddit_login
get '/auth/reddit/callback', to: "sessions#create"

Answer Source

Having this too. Seems like the strategy for omniauth-reddit isn't working correctly.

EDIT: Looks like the issue comes from a newer version of the omniauth-oatuh2 gem.

If you include gem 'omniauth-oauth2', '~> 1.3.1' in your Gemfile, it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download