Login Web App

From Facebook Developers Wiki

Jump to: navigation, search

[edit] Logging a User into a Web Application

This article provides a high level view of the login process for a Web application.

Your canvas page URL may look like this (see below for the code for a sample login button).

Image:Login-webapp.gif

To log in, your application should direct users to a URL like the following: http://www.facebook.com/login.php?api_key=YOUR_API_KEY&v=1.0

If the user is not already logged into Facebook, the user will be directed to a page like this:

Image:Login-login.gif

If the user has never logged into your application before, she'll be asked to accept the Terms of Service for using the application. These are your Terms of Service, not Facebook's. If the user has already accepted the Terms of Service, she skips this step.

Image:Login-tos.gif

The user is then taken to the callback URL, with the auth_token appended to the URL, like this: http://www.yourapp.com/home.php?auth_token=abc123

The user is now successfully logged in to the application.

Image:Login-webapploggedin.gif

On the callback URL, store the auth_token from the URL. You'll use it later to establish a session.

$auth_token = $_GET['auth_token'];

For more detailed information about the login procedure, see the authentication guide.

[edit] Facebook Login Image

You may use this image to display on your site as a link or login to Facebook.

Image:Facebook_login.gif

Please note that you may only use the Facebook name (or any of our other trademarks) in accordance with the Facebook Platform Terms of Service. You will likely use the button in this manner:

<a href="http://www.facebook.com/login.php?api_key=YOUR_API_KEY&v=1.0"><img src="http://static.ak.facebook.com/images/devsite/facebook_login.gif"></a>