RoR - How to obtain an access token for the facebook user using OAuth? - ruby-on-rails

i want create something like "link_to" which can link to "request for permission" in facebook, so if user click "allow" then redirect to my site and i can get their data.
my question is how to create a "link" like that? so i can get access token from facebook user. (i had register my app)
thx..

Better explained here:
http://ggomeze.com/2011/05/19/post-to-facebook-from-rails-app

It's quite simple. Just redirect the user to the Facebook Auth Page:
https://graph.facebook.com/oauth/authorize?
client_id=...&
redirect_uri=http://www.example.com/callback&
scope=user_photos,user_videos,publish_stream
There're several optional parameters you can pass to get the required site.
For further Information just read the corresponding paragraph on the Facebook Documentation ("Authenticating Users in a Web Application"):
http://developers.facebook.com/docs/authentication/

Related

Get Twitter id with Screen Name

Hi I'm trying to get Twitter ID by Screen name..
Screen name is: KTutorials
Here is my link to get Twitter Id
https://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=ktutorials&count=5000
But I'm getting this error.
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
Here is my Twitter link https://twitter.com/ktutorials
Any Help?
I can see that you are using Twitter API to GET followers/ids method. GET request for this method require OAuth Signature. This means that you should have Twitter App created and if not, you should have create one here.
Subsequently, you should visit GET followers/ids documentation page, and get OAuth Signature using the "OAuth Signature Generator" located at bottom of page.
Bad Authentication data tells that you it can't do the operation due to the bad authentication.
From API V1.1, all requests should be authenticated first. So, create
an app in Twitter console and put the important keys like Access keys
and Consumer keys.
If you feel you are authenticated user, then re-generate your token and give another try!

Facebook authentication without requesting friend list

I'd like to use Facebook OAuth authentication for a web application in a business context. What I need is a user ID and nothing else but Facebook by default always says "... will receive the following info: your friend list and email address".
Is there any way to configure Facebook or my application not to request the friend list for which I have no need to know?
By the way, I am using ASP.NET MVC but should be able to make the required adjustments to my application if someone can point me into the right direction.
If you are using Microsoft.Asp.net.Facebook like below tutorial
http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-facebook-birthday-app
You can set the attributes like below to get permissions for required things:
[FacebookAuthorize("email", "user_photos", "user_friends")]
if you don't need friends details remove the attribute.
[FacebookAuthorize("email", "user_photos")]

Get twitter and google+ profile images?

I'm integrating my site with OAuth to facebook, twitter and google+
I can get the facebook profile url, but I'm unable to get any images using the provider Id's im getting back from the dotnetoauth providers.
Twitter
provider user id: 126031206
provider user name: RogerAlsing
Google+
https://www.google.com/accounts/o8/id?id=somecode-alongercode
provider user name: my email
I've seen a few working examples, but they seem to use other IDs than I get here.
Is it possible to get the profile images using any of the above values?
This looks like the OpenID method of authenticating yourself to Google, and not the OAuth2 method that they currently suggest. (And if I'm reading correctly, it looks like an older OpenID method, even.)
Current best practice for Google+ authentication to get profile information is documented at https://developers.google.com/+/web/people/ and https://developers.google.com/+/web/signin/
In particular, for an authenticated user (https://developers.google.com/+/web/signin/), you can make a people.get API call, using the special keyword "me" instead of an ID. This will return the profile picture as part of a Person resource, including other profile information, as well as the Google+ ID. Also, to understand your Google+ ID, the proper link would be https://plus.google.com/u/0/ID/posts which is the link to your Google+ profile.

How can I force login with the OAuth API?

Is there a parameter I can pass to https://www.facebook.com/dialog/oauth that will force the user to login again?
The problem is if the user is logged into Facebook, it will redirect transparently back to my site, even if the user wants to use a different Facebook account.
Twitter's OAuth API accepts a "force_redirect=true" parameter which does what I want, but I can't find one for Facebook.
I think "auth_type=reauthenticate" is the option you are looking for.
Docs: https://developers.facebook.com/docs/reauthentication/

Automatically login to Twitter

I'm doing a little experimentation. The end goal is to open Twitter in a new tab for a user that is already logged in.
I have gone down the oAuth route and I can post to twitter, retrieve tweets etc. but when I visit Twitter.com I still get the login page. I have a couple of questions
A) Is it possible to automaticaslly log a user in like this (I can see why it can't be but need to make sure)
B) Does anyone know of another way to acheive it?
When you redirect the user to twitter to authorize, send them to oauth/authenticate, instead.
This flow is called Sign in with Twitter.

Resources