To integrate Facebook Login into a website or app, you create an app in the Meta for Developers dashboard, add the Facebook Login product, run the login flow on the client with the JavaScript SDK or the native iOS and Android SDKs, and then verify the resulting access token on your server before you trust it. The client side is a few dozen lines. The parts that trip most teams up are the server side token check, the App Review process for anything beyond basic profile data, the mandatory data deletion callback, and the newer Limited Login mode on iOS.
FB.login() (web) or the native SDK login manager (mobile), send the access token to your backend, and validate it there with the Graph API debug_token endpoint using your app access token. Request only public_profile and email unless you are ready for App Review, and register a data deletion callback URL before you go live.This guide walks through the whole facebook login integration in the order you will actually build it: dashboard setup, the browser flow, backend validation, permissions and review, the mobile SDKs, the data deletion requirement, and the errors you will hit along the way. Endpoint examples use Graph API version v25.0, which is the version Meta’s own manual flow documentation currently shows; swap in whatever version your dashboard lists as current.
Step 1: Set up the app in the Meta developer dashboard
Everything starts at developers.facebook.com. Sign in, open My Apps, click Create App, and pick the use case that includes authentication (the dashboard currently phrases this as “Authenticate and request data from users with Facebook Login”). Give the app a name and a contact email, then finish the wizard.
Once the app exists, do these things under App settings > Basic and the Facebook Login product settings:
- Copy the App ID (public, goes in client code) and the App Secret (private, backend only).
- Add your production domain under App Domains and add a Privacy Policy URL and Terms of Service URL. Live mode will refuse to switch on without a privacy policy.
- Under Facebook Login > Settings, add every redirect URI you will use to Valid OAuth Redirect URIs. Localhost is allowed while the app is in development mode.
- Fill in the Data Deletion field (callback URL or instructions URL). More on this below.
Step 2: The JavaScript SDK flow on a website
For a plain website, load the SDK, initialize it with your App ID, and call FB.login() from a click handler. Browsers block popups that are not triggered by a user gesture, so never fire the login call on page load.
<script async defer crossorigin="anonymous"
src="https://connect.facebook.net/en_US/sdk.js"></script>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'YOUR_APP_ID',
cookie: true,
xfbml: false,
version: 'v25.0'
});
};
document.getElementById('fb-login').addEventListener('click', function () {
FB.login(function (response) {
if (response.status === 'connected') {
var token = response.authResponse.accessToken;
fetch('/auth/facebook', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ access_token: token })
});
} else {
console.log('User cancelled or did not fully authorize.');
}
}, { scope: 'public_profile,email' });
});
</script>The callback returns a short lived user access token. Send it to your backend over HTTPS and never trust the user ID that arrives from the browser; anyone can post a fabricated response to your endpoint.
If you do not want the SDK on your page at all, Meta documents a manual redirect flow: send the user to https://www.facebook.com/v25.0/dialog/oauth with client_id, redirect_uri, state and scope, then exchange the returned code at https://graph.facebook.com/v25.0/oauth/access_token using your app secret on the server. Use that pattern if you are building a broader single sign on layer with Facebook.
Step 3: Validate the token on your server
The single most important step in the whole integration is the server side check. Call the Graph API debug_token endpoint, passing the token you received as input_token and an app access token (the string APP_ID|APP_SECRET) as access_token.
GET https://graph.facebook.com/debug_token
?input_token=USER_TOKEN_FROM_CLIENT
&access_token=APP_ID|APP_SECRET
{
"data": {
"app_id": "123456789012345",
"type": "USER",
"application": "My Store",
"expires_at": 1762000000,
"is_valid": true,
"issued_at": 1756800000,
"scopes": ["email", "public_profile"],
"user_id": "10223456789012345"
}
}Your backend should reject the login unless all of the following are true: is_valid is true, app_id matches your own App ID (this blocks tokens minted for someone else’s app), and expires_at is in the future. Only then fetch the profile:
GET https://graph.facebook.com/v25.0/me
?fields=id,name,email
&access_token=USER_TOKEN
&appsecret_proof=HMAC_SHA256(USER_TOKEN, APP_SECRET)Turn on Require App Secret in the app’s Advanced settings so every server call must include appsecret_proof. That way a leaked user token is useless without your secret. Note that email can be missing even when the permission was granted: users who signed up with a phone number, or whose email is unverified, return no email field. Handle that case with a fallback form. For a deeper treatment of token lifetimes and refresh strategies, see our guide on handling Facebook API authentication.
Step 4: Permissions and App Review
Facebook Login permissions fall into two groups, and the split determines whether you need App Review.
| Permission | What it gives you | App Review needed? |
|---|---|---|
| public_profile | App scoped ID, name, profile picture | No (automatically granted) |
| Primary email address if available | No (automatically granted) | |
| user_birthday, user_friends, user_likes, and others | Extended profile data | Yes, with screencast and justification |
| pages_*, instagram_*, ads_* | Business asset access | Yes, plus Business Verification in most cases |
For a login button, public_profile and email are all you need and they work in live mode without review. Anything else requires a review submission with a use case explanation and a screen recording, which commonly takes days to weeks, so launch with the basic permissions first.
scopes array from debug_token (or call /me/permissions) instead of assuming you got everything you asked for. If email was declined you can prompt again with auth_type=rerequest.Step 5: iOS and Android native SDKs
On mobile, use the official SDKs rather than a web view. Meta actively blocks login inside embedded web views, and the native SDKs handle app switching, the system browser, and token storage for you. We cover the general SDK setup in using Facebook SDKs for mobile app development, so here are only the login specifics.
Android
Add the facebook-login dependency, put your App ID and Client Token in strings.xml, register the FacebookActivity and the custom tab activity in the manifest, and register your debug and release key hashes in the dashboard. The login itself is a call to LoginManager.getInstance().logInWithReadPermissions(activity, listOf("public_profile", "email")) with a CallbackManager to receive the result. As on the web, send AccessToken.getCurrentAccessToken().getToken() to your backend and validate it there.
iOS and Limited Login
On iOS you add the FacebookLogin package, add FacebookAppID, FacebookClientToken and FacebookDisplayName to Info.plist, register the fbAPPID URL scheme, and add fbapi and fb-messenger-share-api to LSApplicationQueriesSchemes. Then call LoginManager().logIn(configuration:).
The iOS specific twist is Limited Login. When you configure the login with tracking: .limited, the SDK performs a login that does not enable tracking, and instead of a classic access token you receive an AuthenticationToken, which is an OpenID Connect ID token (a JWT). Meta’s documentation notes two consequences: app switching into the Facebook app is not supported for limited flows, and permissions that are incompatible with limited tracking, such as user_likes, cannot be requested. In practice, if your app does not obtain App Tracking Transparency consent, you should build for Limited Login on iOS.
Because the ID token is a JWT rather than a Graph API token, the server side validation differs. You cannot pass it to debug_token. Instead, verify the signature against Meta’s JWKS at https://limited.facebook.com/.well-known/oauth/openid/jwks/, confirm the iss claim is https://www.facebook.com, confirm aud equals your App ID, check exp, and compare the nonce claim with the nonce your app generated before login. The sub claim is the app scoped user ID.
# Python example with PyJWT
import jwt
from jwt import PyJWKClient
jwks = PyJWKClient("https://limited.facebook.com/.well-known/oauth/openid/jwks/")
key = jwks.get_signing_key_from_jwt(id_token).key
claims = jwt.decode(
id_token, key, algorithms=["RS256"],
audience=APP_ID, issuer="https://www.facebook.com"
)
assert claims["nonce"] == expected_nonce
user_id = claims["sub"]Step 6: The data deletion callback
Meta requires every app that uses Facebook Login to offer a way for users to request deletion of their data. In App settings > Basic you must supply either a Data Deletion Instructions URL (a page explaining how to request deletion manually) or a Data Deletion Request Callback URL. The callback is the better option because it removes a manual support step.
When a user removes your app from their Facebook settings and asks for deletion, Meta sends an HTTPS POST to your callback with a signed_request parameter. The value is a base64url encoded HMAC SHA256 signature, a period, and a base64url encoded JSON payload containing algorithm, user_id, issued_at and expires. You verify the signature with your app secret, delete or anonymize everything tied to that user_id, and respond with JSON containing a status URL and a confirmation code:
{
"url": "https://example.com/deletion-status?id=abc123",
"confirmation_code": "abc123"
}The status URL should show the user a human readable explanation of where their request stands; Meta’s data deletion callback documentation has the full contract. Build this before launch, because it is required to move the app to live mode.
Troubleshooting common errors
“URL Blocked: This redirect failed because the redirect URI is not whitelisted”
The redirect_uri you send must match, character for character, one of the Valid OAuth Redirect URIs in Facebook Login settings, including the scheme, trailing slash and any query string. Add the exact URL and try again. Also confirm the domain is in App Domains.
“Can’t Load URL: The domain of this URL isn’t included in the app’s domains”
Same root cause as above but for the JavaScript SDK. Add the site domain under App Domains, and if you use the JavaScript SDK make sure the domain is listed under Allowed Domains for the JavaScript SDK in the Login settings.
“App Not Setup: This app is still in development mode”
Real users cannot log in while the app is in development mode. Either add them as testers or complete the live mode requirements (privacy policy, data deletion, icon, category) and flip the switch at the top of the dashboard.
Invalid key hash on Android
Generate the key hash from the exact keystore that signed the build (debug keystore for debug builds, upload key or Play App Signing key for release builds) and register every hash in the dashboard. Play App Signing uses a different key than your upload key, so you usually need both.
Frequently asked questions
Do I need App Review just to add a Facebook Login button?
No. The public_profile and email permissions are granted automatically and work in live mode without review. You only need App Review when you request additional permissions such as friends lists, birthdays, or page and Instagram access, and Business Verification when you touch business assets.
How long does a Facebook access token last?
The token returned by the client SDKs is short lived, typically around an hour or two. You can exchange it on the server for a long lived token that lasts roughly sixty days using the fb_exchange_token grant. For plain login you usually do not need this; validate once, then issue your own session.
Can I use Facebook Login inside a web view in my mobile app?
No. Meta blocks Facebook Login in embedded web views for security reasons, and the login dialog will error out. Use the official iOS or Android SDK, which opens the system browser or the Facebook app, or use a system browser tab and the manual OAuth redirect flow with a custom URL scheme.
What is Limited Login and do I have to use it?
Limited Login is an iOS mode where the SDK performs authentication without enabling tracking and returns an OpenID Connect ID token instead of a Graph API access token. If your app cannot or does not obtain App Tracking Transparency consent, you should use it. Your backend must validate the JWT rather than calling debug_token.
Is the data deletion callback really mandatory?
Yes. Meta requires either a data deletion callback URL or a deletion instructions URL in the app’s basic settings, and you cannot switch the app to live mode without one. The callback receives a signed request containing the user ID and must respond with a status URL and confirmation code.
The bottom line
A working facebook login integration comes down to four pieces: correct dashboard configuration (domains, redirect URIs, privacy policy, data deletion), a client login flow using the JavaScript SDK or the native SDKs, server side validation with debug_token or JWT verification for Limited Login, and a disciplined approach to permissions so you avoid App Review until you truly need it.
Get the server side check right first, launch with only public_profile and email, and build the deletion callback before you request live mode. Once login is stable, the same app can power richer social features, such as the Facebook comments plugin, without any additional authentication work.
About this article: GeekBlog covers U.S. technology news, AI, phones, smartwatches and gaming. Every story is written and checked under our Editorial Policy. Spotted a mistake or have a story tip? Contact our editors.

