Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OAuth authentication like Facebook

I need to authenticate by OAuth to some sites (e. g. flickr) by Javascript and I want to make experience similar to what Facebook login-button does. When you click login-button a popup window is opened, you authenticate and then popup window is closed and onlogin event of login-button is raised.

Is there any Javascript library which implements this behavior for OAuth?

like image 218
SiberianGuy Avatar asked May 12 '12 09:05

SiberianGuy


People also ask

What is OAuth and how does it work?

This mechanism is used by companies such as Google, Facebook, Microsoft and Twitter to permit the users to share information about their accounts with third party applications or websites.” In simple language, OAuth (Open Authorization) is an open standard for token-based authentication and authorization on the Internet.

What are the requirements for using OAuth2?

Only one requirement exists; that is, the user must authorize the application to access their data for a selected OAuth provider. Users can sign up or log in to any application that are using OAuth2 without using any credentials such as email id and/or password.

How do I redirect a user back to Facebook after authorization?

After, click the Save button. Then, skip the rest of the steps and click the Settings option in the left-hand menu. In the Settings page, you need to add redirect URL in order to tell Facebook where a user will be redirected back after authorization. Here, again, I am using localhost for doing this.

How to add Facebook login functionality to your website?

Then, you need to choose the platform for which you want to add Facebook login functionality to. Select the www option. From there, you need to enter the URL of your website. If you do not have a site in production, you can definitely use localhost. I used http://localhost:8000 for this application.


2 Answers

This is a feature of OAuth 2.0, which specifies a client-side flow which facilitates this.

The spec is here and Google's implementation of it is described here.

Support for this is included in the google-api-javascript-client (for Google APIs and login) and there is a general library that will work with supported providers called gwt-oauth2 -- it's written in GWT, but is also usable in a standard JavaScript environment.

edit: Microsoft's Live Connect library appears to support this flavor of OAuth 2.0 as well.

Unfortunately, Flickr does not appear to have support for this, as it only seems to support OAuth 1.0a.

But there some popular providers that do support the client-side OAuth 2.0 flow:

  • Google
  • Facebook
  • Foursquare
  • Instagram
  • DailyMotion
  • Windows Live

You could run your own server to make OAuth 1.0a requests to Flickr and send back OAuth 2.0 access tokens to the JavaScript client, I suppose.

like image 136
Jason Hall Avatar answered Oct 17 '22 18:10

Jason Hall


I am certain janrain offers authentication to sevaral sites using node.js, I would give it a peek. Also try this example

like image 2
thechrisberry Avatar answered Oct 17 '22 16:10

thechrisberry