omniauth OAuthException & OAuth::Unauthorized

爱⌒轻易说出口 提交于 2019-11-30 13:41:24

Alex D. is correct in that the ENV[] breaks it. To create omniauth.rb so that it uses different keys in different environments just put:

provider :twitter, TWITTER_KEY, TWITTER_SECRET

in omniauth.rb

and then in your environment config files (config/environments/development.rb, etc.) put the key you want to use for that environment.

config/environments/development.rb:

TWITTER_KEY = 'aaaaaaa'
TWITTER_SECRET = 'aaaabbbbbb'

config/environments/production.rb:

TWITTER_KEY = 'ccccccc'
TWITTER_SECRET = 'ccccdddddd'

ENV['something']

looks into your environment vars for "something", so it would expect

something='12345'

so you should do it like that

export AUTH_FB_KEY='....'
export AUTH_FB_SECRET='...'

check with

env

and update your config

provider :facebook, ENV['AUTH_FB_KEY'], ENV['AUTH_FB_SECRET']

if you use heroku

heroku config:add AUTH_FB_KEY='....'

There have been breaking changes made in omniauth 1.0 - https://github.com/intridea/omniauth

OmniAuth 1.0 has several breaking changes from version 0.x. You can set the dependency to ~> 0.3.2 if you do not wish to make the more difficult upgrade. See the wiki for more information.

I would try reverting omniauth to 0.3.2:

gem install omniauth --version '~> 0.3.2'

or if you're using bundler, in your Gemfile:

gem omniauth, '~> 0.3.2'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!