ruby '2.6.3'
gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
I'm using the latest omniauth-facebook and devise together
Gemfile:
gem 'devise'
gem 'omniauth-facebook'
Getting this error when starting the server:
/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `': You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed. (RuntimeError)
The problem is that if I try to use older omniauth-facebook versions the server works but then the Facebook authentication stops working properly (e.g. fails including emails despite
scope: 'email', info_fields: 'email,name'
in devise.rb. )
I have tried many different version combinations of omniauth-facebook and devise. Either Facebook-authentication stops working properly or the server fails (see above).
Using
gem 'devise', github: 'heartcombo/devise', branch: 'ca-omniauth-2'
In Gemfile will fix the problem, awaiting a merge.
Updated my answer based on Carlos answer below, I was in a rush when I posted this using ref.
Thank You, Carlos for maintaining Devise.
This is Carlos, Devise maintainer. Please keep an eye on that Pull Request linked above, I just shared how you can test it in your app there:
I'd recommend using the branch ref instead of the git ref directly:
gem 'devise', github: 'heartcombo/devise', branch: 'ca-omniauth-2'
With that you should be able to run bundle update devise omniauth which should hopefully give you OmniAuth 2 and this Devise branch. That should allow the app to boot up.
Lastly, if you've copied over the Devise shared links on your app, or if you have your own links to initiate the OmniAuth authentication flow, you need to make sure they're changed to use a form. (you can do that by using link_to with method: :post option for example, or using button_to, if that works for your app.) Please note that this is a requirement change in how OmniAuth work due to a security issue, read more.
If you run into any issues please comment back in GitHub, and we'll work to get them resolved soon so we can release a new Devise version that fully supports OmniAuth 2. Thanks.
Devise 4.8.0 (shipped yesterday) resolves this.
Please downgrade OmniAuth:
gem "omniauth", "~> 1.9.1"
That's worked for me.
I'm pretty sure the issue is related to this devise PR, https://github.com/heartcombo/devise/pull/5327
Devise currently has a version check that doesn't include OmaniAuth > 1.x.x
Related
I'm trying to wrap my head around why a problem I was struggling with is now magically resolved.
I am building a Rails app that uses Spotify OAuth (via the rspotify gem) and became stuck on the exact issue described here. After spinning my wheels, I finally came across this comment, recommending that I explicitly add the omniauth gem to my Gemfile.
Now, this omniauth gem was already a dependency in Gemfile.lock for omniauth-oauth2 specifically. As the linked comment recommends, I included omniauth in my Gemfile and now my problem is seemingly resolved, but I don't really know why.
Why does including a gem in your Gemfile resolve a railtie issue in this case?
If a gem is already installed as a dependency (according to Gemfile.lock) isn't that evidence that a given gem was installed? If, say, gem_foo is listed as a dependency in Gemfile.lock and I add gem_foo in Gemfile and then run Bundler, how does Rails interpret this change?
This is related to how gems are loaded by bundler. Bundler.require requires gems listed in Gemfile but does not require its dependecy. Its upto the library to require/load its dependency.
The mentioned issue happens when omniauth is not added explicitly to Gemfile, hence bundler does not require it.
But since omniauth-rails_csrf_protection assumes the ominauth is already required, it errors out when user only adds omniauth-rails_csrf_protection but does not add omniauth to Gemfile.
I have created a possible fix for the issue https://github.com/cookpad/omniauth-rails_csrf_protection/pull/13
UPDATE: The is fix has been merged in the gem repo.
I am adding facebook authentication to my web app. Problem is that after I bundle installed the gems, it did not create this file.
config/initializers/omniauth.rb
Has anyone had this problem?
Gems:
#user authentication
gem 'devise'
gem 'opro'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'oauth2'
It shouldn't be a problem. It doesn't create it automatically and you don't need to create it manually either as you seem to be using it in conjunction with devise. Instead, you can use the config.omniauth setting in your devise.rb initialiser. Have you read the relevant devise wiki page? https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview
Also, note that you don't really need to specify omniauth and oauth2 in your Gemfile as they are dependencies of omniauth-facebook, so bundler should pull them in automatically.
I create rails app deployed on Heroku.
also, exception_notification gem enabled.
when it is on development setup ActionMailer to Gmail,
everything is fine and sends a notification from Gmail address.
but when it comes to production environment on Heroku,
I get following error when server trying to send a email.
ActionView::Template::Error (code converter not found (UTF-8 to UTF-16))
Could anyone tell me what's happening here?
The issue was raised on the main repository (see here), but so far was not addressed.
You might want to take a look at this fork to the exception_notification gem, specifically this commit which tries to deal with the problem:
https://github.com/alanjds/exception_notification/commit/048fc6be972189e62ca3b9453d19233ec5773016
To use this fork I pointed the gem to it, like so:
Gemfile:
gem 'exception_notification', git: 'git://github.com/alanjds/exception_notification.git'
This solved the issue for me.
Quick adjustment to solution by hananamar, otherwise you'll get an error:
gem 'exception_notification', :git => 'git://github.com/alanjds/exception_notification.git', :require => 'exception_notifier'
I know this is an old post but since I got the same issue some days ago, I wanted to share here that I solved it by forcing the latest version of the gem on my Heroku app.
gem 'exception_notification', '3.0.1'
I guess the problem was with version 3.0.0 and it is fixed on 3.0.1.
Has any one come across this error?
NoMethodError (undefined method `new' for LinkedIn:Module)
I think it's related to omniauth and linkedin. Here's my Gemfile:
gem 'omniauth'
gem 'linkedin', :git => "git://github.com/redbeard-tech/linkedin.git", :branch => 'jsapi'
I'm using:
ruby 1.8.7 (2010-01-10 patchlevel 249)
rails 3.0.5
What might be the reason for it?
Check what version of omniauth you are using. We recently ran into this and it was from our dev environment having omniauth 0.3.x and the new environment getting the new 1.0 release. On the omniauth github site it says:
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 suspect you're being bitten by that.
From the error message it looks like you are calling LinkedIn.new(...), but looking at the documentation it seems like it should be LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret'). LinkedIn is a module, not a class and therefore doesn't have a new method. However, there seems to be class called Client defined within this module, which you have to instantiate.
I want to use ebayapi gem (https://github.com/codyfauser/ebay) with my rails 3.1 application.
If I add the gem in the Gemfile, rails doesn't run.
/Users/ssk/.rvm/gems/ree-1.8.7-2011.03/gems/money-1.7.1/lib/support/cattr_accessor.rb:7:in `cattr_reader': undefined method `id2name' for {:instance_writer=>true}:Hash (NoMethodError)
I removed the ebayapi gem and tried "require 'ebay'" but it said that "no such file to load".
Ebayapi gem works only with money 1.7.1 and I think that conflicts with rails 3.1 (maybe 3.0 as well).
Is there a way to workaround?
Thanks.
Sam
If it's truly incompatible, and you're up to fixing it yourself, then fork the projects in question on github, and update your Gemfile to point to your git repo (or even a local path to make editing a lot easier).
Here's an example:
gem 'money', :path => "~/dev/ruby/gems/money"
# or
gem 'money', :git => "git://github.com/my_account/money.git"
Once you've fixed it, send a pull request to the original project so they can include the fix.