background preloader

Authentication

Facebook Twitter

Authentication for Devices. Please note that we are currently testing Device Login with a limited number of partners. It is not currently available for general use, and we are not accepting additional applications for access. For some devices with limited input peripherals, or for devices which do not support HTML, asking users to input their email address and password just to log into Facebook can be cumbersome. Facebook Platform offers an login flow - the Device Flow - to give users a quick, simple alternative.

With the Device flow, a user presses a button on their device. The device then displays a short code generated by Facebook, and the user then types this code into Facebook in a standard web-browser in order to authorize that device to access their Facebook data. Facebook's implementation of device flow is based on Section 3.7 of the OAuth 2.05 specification. This guide will walk you through the following: Sample Overview For a working example of this login flow, please see the OAuth Device Demo. Server-Side Authentication. Whether someone is not logged into your app or not logged into Facebook, you can use the Login dialog to prompt them to do both.

Server-Side Authentication

If they aren't logged into Facebook, they'll be prompted to login and then move onto logging into your app. This is automatically detected, so you don't need to do anything extra to enable this behavior. Invoking the login dialog Your app must initiate a redirect to an endpoint which will display the login dialog: client_id={app-id} &redirect_uri={redirect-uri} This endpoint has the following required parameters: client_id. It also has the following optional parameters: state. Client-Side Authentication. Authentication within a Canvas Page.

Whether someone is not logged into your app or not logged into Facebook, you can use the Login Dialog to prompt them to do both.

Authentication within a Canvas Page

If they aren't logged into Facebook, they'll be first prompted to login, and then move onto logging into your app - this is automatically detected, so you don't need to do anything extra to enable this behavior. Invoking the Login Dialog Games on Facebook have a number of options for invoking the Login Dialog, depending on which type of login flow they are using: For apps using the Facebook SDK for JavaScript, the Login Dialog can be invoked with a simple call as shown in the Login Flow for Web guideFor apps not using this SDK, the Login Dialog is invoked with a redirect. This process has a slight caveat for apps in canvas: Because your game is loaded in an iframe, returning a 302 to redirect the user to the Login Dialog will be unsuccessful. Authentication within a Page Tab.

Whether someone is not logged into your app or not logged into Facebook, you can use the Login Dialog to prompt them to do both.

Authentication within a Page Tab

If they aren't logged into Facebook, they'll be first prompted to login, and then move onto logging into your app - this is automatically detected, so you don't need to do anything extra to enable this behavior. Invoking the Login Dialog Games on Facebook have a number of options for invoking the Login Dialog, depending on which type of login flow they are using: SDK for iOS Tutorial. The SDK comes with samples that demonstrate some of its features.

SDK for iOS Tutorial

To find and run these samples, download the SDK, and then click on the .pkg file and follow the wizard to install it. Once the SDK is installed, go to the FacebookSDK folder (located by default inside your Documents folder), and there you will find a Samples folder that contains the samples you're looking for. You can run them from Xcode in the iPhone simulator. FriendPickerSample Demonstrates how to use a FBFriendPickerViewController in the Facebook SDK for iOS.

GraphApiSample Demonstrates the basics of how to make a (single or batch) request using the Facebook SDK for iOS. HelloFacebookSample Demonstrates some basic usage of the Facebook SDK, including: PlacePickerSample. Android Tutorial. To use Facebook SDK in a project, add it as a build dependency and import it. 1.

Android Tutorial

Go to Android Studio | New Project | Minimum SDK 2. Select API 15: Android 4.0.3 or higher and create your new project. 3. 4. Repositories { mavenCentral() } Authentication. Handling Invalid and Expired Access Tokens. Permissions Reference. When a person logs into your app via Facebook Login you can access a subset of that person's data stored on Facebook.

Permissions Reference

Permissions are how you ask someone if you can access that data. A person's privacy settings combined with what you ask for will determine what you can access. Permissions are strings that are passed along with a login request or an API call. Here are two examples of permissions: email - Access to a person's primary email address.user_likes - Access to the list of things a person likes. For example, if you add the login button to a web app and ask for email and user_likes via the scope parameter, a person would be prompted with this dialog when logging in for the first time: Your app has requested a person's email address and the things they like but that request also automatically asks for access to a person's public profile.

We provide similar mechanisms for iOS and Android.