I am using omniauth-oauth2
,omniauth-google-oauth2
,omniauth-linkedin-oauth2
,omniauth-facebook
,omniauth-twitter
gems for Authentication of my basic rails app hosted in aws ec2.Facebook and Twitter Authentication is working fine but while Authentication with Linkedin and google+ are rendering the message "Not found. Authentication passthru." Facebook and Twitter are working fine.please help me with the problem .Any help is highly Appreciated.
Thanks in Advance.
Gemfile
ruby '2.3.1'
gem 'devise', '~> 4.2'
gem 'koala', '~> 2.4'
gem 'linkedin', '~> 1.1'
gem 'omniauth-oauth2', '~> 1.4'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-twitter'
gem 'omniauth-linkedin-oauth2', '~> 0.1.5'
devise.rb
config.omniauth :facebook, "356781xxxxx", "1686997c451aecfd12dc7bxxxxxx",
scope: 'email', info_fields: 'email',
callback_url: "http://ec2-xx-xxx-xx-xx.us-west- 2.compute.amazonaws.com/users/auth/facebook/callback"
config.omniauth :twitter, "HnA4m6IzaZ1haT9nxxxxxxx", "SsL6TiWFLkKDWnta5zRek7YBvwfPBfMEiNYWRVxxxxxxxxxxx",
callback_url: "http://ec2-xx-xxx-xx-xx.us-west- 2.compute.amazonaws.com/users/auth/twitter/callback"
config.omniauth :google_oauth2,"115059498414- 5fj2in117vueg4a1tdg52xxxxxxxxx.apps.googleusercontent.com","
ZbPzUjSKpYRTmxxxxxxx",
{
:name => "google",
:scope => "email, profile, plus.me",
:prompt => "select_account",
:image_aspect_ratio => "square",
:info_fields => "id,name,link",
:image_size => 50
}
require "omniauth-linkedin-oauth2"
config.omniauth :linkedin, "811sfhxxxxxx","Pe2wtfRbxxxxx",:scope => 'r_fullprofile r_emailaddress'
users/omniauth_callbacks_controller.rb
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_action :verify_authenticity_token
def sign_in_with(provider_name)
@user = User.from_omniauth(request.env["omniauth.auth"])
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice, :success, :kind => provider_name) if is_navigational_format?
end
def facebook
sign_in_with "Facebook"
end
def linkedin
sign_in_with "LinkedIn"
end
def twitter
sign_in_with "Twitter"
end
def google_oauth2
sign_in_with "Google"
end
def developer
sign_in_with "Developer"
end
end
user.rb
class User < ActiveRecord::Base
devise :rememberable, :trackable, :omniauthable,
:omniauth_providers => [:twitter,:facebook,
:linkedin_oauth2, :google_oauth2,
*(:developer if Rails.env.development?)]
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = auth.info.email
end
end
end
routes.rb
Rails.application.routes.draw do
devise_for :users, :controllers => {
:omniauth_callbacks => "users/omniauth_callbacks"
}
devise_scope :user do
get 'sign_in', :to => 'devise/sessions#new', :as => :new_user_session
delete 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session
end
root 'home#index'
end
callback URL to my app site in google developer account:
Authorized JavaScript origins : http://ec2-xx-xxx-xx-xx.us-west
Authorized redirect URIs : ec2-xx-xxx-xx-xx.us-west/users/auth/google/callback
also tried with
ec2-xx-xxx-xx-xx.us-west/users/auth/google_oauth2/callback
callback URL to my app site in linkedin developer account:
OAuth 2.0 Authorized Redirect URLs:
ec2-xx-xxx-xx-xx.us-west/users/auth/linkedin/callback
ec2-xx-xxx-xx-xx.us-west/users/auth/linkedin_oauth2/callback
even tried with OAuth 1.0a Default "Accept" Redirect URL:
ec2-xx-xxx-xx-xx.us-west-/users/auth/linkedin/callback