I am currently developing a Rails web application that requires a user to login through LinkedIn. After that I want to embed the Member Profile plugin in his/her profile page.
For that to happen I need to have the public URL, without it the plugin will not work. I already have full profile permission r_fullprofile on LinkedIn login. But still I am not able to find the API to extract public url.
Is there a way to get that URL?
You can specify public-profile-url as a default field:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :linkedin, "consumer_key", "consumer_secret", :scope => 'r_fullprofile r_emailaddress r_network', :fields => ["id", "email-address", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url", "location", "connections"]
end
and then using the pengwynn LinkedIn gem you can access the URL like so:
client = LinkedIn::Client.new
client.authorize_from_access("access_token", "access_token_secret")
client.profile(:fields => ["public-profile-url"])
Related
In my omniauth.rb
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, Rails.application.secrets[:facebook_app_id], Rails.application.secrets[:facebook_secret], :scope => 'email,public_profile', :display => 'popup', :info_fields => 'email,public_profile'
end
Client side, javascript:
return FB.login(function(response) {
if (response.authResponse) {
return window.location = '/auth/facebook/callback;
}
}, {scope: 'email,public_profile'});
as per the FB API docs.
When the FB popup opens to ask for permissions, it correctly asks for email and public_profile. I hit OK and this is what request.env['omniauth.auth] provides me with only:
{"provider":"facebook","uid":"XXXXXXX","info":{"name":"XXXXXXX
XXXXXXX","image":"http://graph.facebook.com/XXXXXXX/picture"},"credentials":{"token":"XXXXXXX","expires_at":1444467600,"expires":true},"extra":{"raw_info":{"name":"XXXXXXX
XXXXXXX","id":"XXXXXXX"}}}
I see neither the email address nor any public info except the full name and the profile picture.
I have no clue what I'm doing wrong as I follow exactly the guidelines of the omniauth-facebook gem here: https://github.com/mkdynamic/omniauth-facebook and also the FB developer docs.
Any hints?
You are on the right path just need to update the info fields with the fields you want to pull from facebook, public_profile won't work
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, Rails.application.secrets[:facebook_app_id], Rails.application.secrets[:facebook_secret], :scope => 'email', :display => 'popup', :info_fields => 'email,first_name,last_name'
end
I'm using Devise and the omniauth-linkedin gem to allow users to log into my Rails app with a LinkedIn account (Rails 4.1.8, Devise 3.4.0, omniauth-linkedin 0.2.0). I've had no trouble getting the user's primary email from LinkedIn, but I'm wondering, is it possible to get a list of ALL the emails associated with the user's LinkedIn account, including non-primary emails?
The LinkedIn docs (https://developer.linkedin.com/documents/authentication) don't say how to do this, but they also don't say that it's impossible.
If it IS possible, what scopes/fields do I need to add to my Devise config? Currently the relevant line in config/devise.rb looks like this:
config.omniauth :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'],
scope: 'r_fullprofile r_emailaddress r_network w_messages',
fields: ["id", "email-address", "first-name", "last-name", "headline",
"industry", "picture-url", "public-profile-url", "location",
"connections"]
The LinkedIn Profile API does not expose email addresses other than the primary one associated with a member profile.
I'm using the Sorcery gem and their external module to authenticate with Twitter. I've got the authentication working, but I want to store the user's Twitter profile image URL in my database after a successful log in. Sorcery seems to have a configuration option that's meant to do exactly what I want:
config.twitter.user_info_mapping = {:nickname => "screen_name"}
Maybe I've missed something in the Sorcery documentation, but I can't find any information about what "keys" are available. I tried this to no avail:
config.twitter.user_info_mapping = {:nickname => "screen_name", :avatar_url => "profile_image_url"}
Has anyone found documentation about this?
That is just what you get from twitter in json format.
Here is a twitter documentation about it https://dev.twitter.com/docs/api/1/get/account/verify_credentials
config.twitter.user_info_mapping = {:username => "screen_name",
:realname => "name",
:location => "place",
:web => "url",
:bio => "description"}
after i added an application in twitter when i request for an authentication in twitter (/auth/twitter) i get these error message
http://localhost:3000/auth/failure?message=invalid_credentials
Routing Error
No route matches "/auth/failure"
how can i add a valid credential or is there any ssl certificate that must be included in requesting for twitter auth??
my facebook authentication just works fine after i added a parameter ssl certificate that looks like this
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook,'xxx', 'xx', { :scope => 'publish_stream,offline_access,email',:client_options => { :ssl =>{ :ca_path => "/etc/ssl/certs" } }}
provider :twitter, 'xx','xxx' #,{ :client_options => { :ssl =>{ :ca_path => "/etc/ssl/certs" } }}
end
i've same problem with you, it happen because oauth_token in twitter login only valid on once request. May be your application trying to refresh when authentication to twitter.
when i've problem like you, my apps trying to refresh the webpage with
window.opener.location = "#{request.fullpath}";
Until now i'couldn't find how to popup a window when login using twitter. I'm using omniauth and rails 3.0.3. Thanks
This is all you need
site url http://localhost:3000/
My current /config/initializers/omniauth.rb file contains:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
end
When I login via Google by going to /auth/google, Google reports:
DOMAIN is asking for some information from your Google Account EMAIL
- Email address: NAME (EMAIL)
My application doesn't need the user's email and so I'd like to remove this barrier to entry. Is there anyway to remove this requirement. For Facebook, I've found I can add the "scope" property of options, for example:
provider :facebook, 'APP_ID', 'APP_SECRET', {:scope => ''}
Based on a quick review of the source for the OpenID strategy (which Google Aps auth inherits from), you can pass in options specifying which attributes are optional vs. required for an Attributes Exchange (AX) auth.
See source code here for options: https://github.com/intridea/omniauth/blob/master/oa-openid/lib/omniauth/strategies/open_id.rb
Based on that, I think you could change the options like so to remove email as a required attribute:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id', :required => [], :optional => []
end
Good luck. I didn't test this, just reading the source.