Omniauth and LinkedIn: Step 3 - ruby-on-rails

Can anyone help with LinkedIn's instructions for setting up omniauth.
I'm really struggling to understand how to set it up in my Rails 4, Devise, Omniauth app.
I'm currently getting this error: Invalid redirect_uri. This value must match a URL registered with the API Key.
The LinkedIn Developer instructions suggest this is an error with Step 1. I have registered my app.https://developer.linkedin.com/documents/authentication
I don't understand how to do step 3. Where do I put the redirect code? How does it work with the rails config. Please can someone help.
Thank you

Basically the step 3 it's saying that you can ask for different permissions in each request by the url, but for your gem you should not worry about this, just skip to the configuration(step 4) of your app in linkedin(settings) and select witch permission to use with all users, this will trigger ask the same for all the user of your page.
Now if you really want to have different behaviors for each user, lets say some users will just login and other will manage their linkedin profile thought your page, you should change the behavior of the workflow of omniauth, facebook-omniauth-gem have an option called setup that you can pass into config.omaniauth in devise initializer, this will trigger an extra step to change the url and there you can put that options, i imagine that linkedin should have something similar.
I just do an answer for facebook, but i explained for general use, look at that if you have troubles, regards!

Related

Facebook login on iPhone. Authenticate with Rails Backend (Devise+Omniauth)

I am trying to implement a facebook user authentication in my iOS6 App through my Rails Backend running with Devise using omniauth. I am looking for a step by step guide how to setup my API and Devise + Authentication.
I only have a only have a rough knowledge about how to do that.
(on App) check if the user signs in on his facebook on iPhone
iPhone is authenticated client sided on Facebook. FB passes me his mobile auth token
I send my auth token or auth hash to my rails backend via API RESTful SSL.
Rails receives the Token and checks if it is valid. ( What command uses the least traffic against FB Graph API? with Koala Gem)
If valid. Check if the user already exists. If not, create a new user.
Create a new session.
Is this correct?
Are there any good examples?
Thank you very much.
I'm not familiar with the iPhone piece, but your approach after that is generally accurate. The only exception is that you would typically use provider + uid to find or create a user, rather than a token. That might be what you meant by your #5, but it wasn't clear to me.
Beyond that, there is a good (paid) Railscast on the subject of Omniauth + Devise, which would probably be worth the price for you:
http://railscasts.com/episodes/235-devise-and-omniauth-revised
It covers how you can receive and handle the auth hash, and it gives you a nice starting point for what your methods will look like.
if you don't access to pro episodes i have some links to help.
http://jessewolgamott.com/blog/2012/01/19/the-one-with-a-json-api-login-using-devise/
you can also look into it
http://net.tutsplus.com/tutorials/ruby/how-to-use-omniauth-to-authenticate-your-users/
Nice and easy to code
http://blog.joshsoftware.com/2010/12/16/multiple-applications-with-devise-omniauth-and-single-sign-on/
I hope these will work for you :)
http://www.orhancanceylan.com/rails-twitter-and-facebook-authentications-with-omniauth-and-devise/

Direct sign in link with devise

For some reason we need to provide a direct sign on link to our user by email.
something like:
www.website.com/user/sign_in/:hash
And the user click on the link he would be automatically sign in.
But I have no idea where to start and it doesn't seem to be built in the gem.
You'll want to use an auth token to sign the user in directly. This SO answer probably has all the details you need on getting this implemented properly.

How to integrate facebook comments in Rails application?

I've set up a Rails 3.2 application with Devise. I was wondering how I can allow users to comment using Facebook. Can I use facebook connect along with Devise? If I can, is it ok to have 2 methods of authentication on my site?
I've read some tutorials on setting up OAuth with Devise to allow facebook connect, but it's not all that clear to me. Does anyone know a good step-by-step tutorial on how to integrate facebook comments with Devise already set up? Thanks a lot!
You don't need to setup Facebook Connect for comments.
You have to first create a Facebook app, then generate the comments plugin. After, put the Javascript code in your application.html.erb after the body tag (my suggestion is to make a partial). In the end, drop the div with the fb-comments class where you want the comments box to appear.

Rails app connect to twitter

I am new Rails developer. Right now, I can let user register in my Rails App. I have database running also.
Todo:
After user register. I will ask permission to access his twitter. And I can access his tweets(including location information in tweets).
About this part, I have no idea how to do now? Can anyone give some links where I should start? I guess first step is I need authentication from twitter right?
Thanks
You are right, first of all you need authentication user from twitter: railscasts. Then you will find all methods there twitter api

twitter connect and rails

I am reading this tutorial: http://blog.dhavalparikh.co.in/2009/06/step-by-step-twitter-oauth-integration-with-rails/
OK, first redirect to twitter connect page. When I allow the connection, twitter redirect to https://twitter.com/oauth/authorize with a code for connect but this must redirect to a action which connect and create a new user in my db.
SO which could be the problem? How i must config the twitter application callback url and app url for localhost.
please i need this answer
Thanks in advance
This doesn't really answer your question but is a nicer way to do this.
Omniauth is a nice gem for rails that makes it very easy to offer twitter, facebook etc. login.
A good intro to this was created by Ryan Bates of Railscasts.
The problem is: Twitter send the token information via post. SO i receive the token by params.
Also there is a problem with oauth 0.4.
I am using oauth 0.3.4 because work in the correct form when twitter try redirect to callback url.

Resources