Facebook 구성 아래에 나열된 URI를 트위터 앱의 유효한 OAuth 리디렉션 URI로 구성합니다. Identity Platform에서 커스텀 도메인을 구성한 경우 기본 도메인 대신 커스텀 도메인을 사용하도록 Facebook 앱 구성의 리디렉션 URI를 업데이트합니다. 예를 들어 https://myproject.firebaseapp.com/__/auth/handler를 https://auth.myownpersonaldomain.com/__/auth/handler로 변경합니다.
승인된 도메인 아래의 도메인 추가를 클릭하여 앱의 도메인을 등록합니다. 개발 용도로는 localhost가 이미 기본적으로 사용 설정되어 있습니다.
Facebook 공급업체 객체를 사용하여 사용자를 로그인 처리합니다. 팝업 창을 열거나 현재 페이지를 리디렉션할 수 있습니다. 휴대기기에서는 사용자가 리디렉션하기 더 용이합니다.
signInWithPopup()을 호출하면 팝업이 나타납니다.
자바스크립트
firebase.auth().signInWithPopup(provider).then((result)=>{/** @type {firebase.auth.OAuthCredential} */varcredential=result.credential;// The signed-in user info.varuser=result.user;// This gives you a Facebook Access Token. You can use it to access the Facebook API.varaccessToken=credential.accessToken;// ...}).catch((error)=>{// Handle Errors here.varerrorCode=error.code;varerrorMessage=error.message;// The email of the user's account used.varemail=error.email;// The firebase.auth.AuthCredential type that was used.varcredential=error.credential;// ...});
페이지를 리디렉션하려면 먼저 signInWithRedirect()를 호출합니다.
signInWithRedirect, linkWithRedirect, reauthenticateWithRedirect를 사용할 때는 권장사항을 따르세요.
자바스크립트
firebase.auth().signInWithRedirect(provider);
그런 다음 페이지가 로드될 때 getRedirectResult()를 호출하여 Facebook 토큰을 검색합니다.
자바스크립트
firebase.auth().getRedirectResult().then((result)=>{if(result.credential){/** @type {firebase.auth.OAuthCredential} */varcredential=result.credential;// This gives you a Facebook Access Token. You can use it to access the Facebook API.vartoken=credential.accessToken;// ...}// The signed-in user info.varuser=result.user;}).catch((error)=>{// Handle Errors here.varerrorCode=error.code;varerrorMessage=error.message;// The email of the user's account used.varemail=error.email;// The firebase.auth.AuthCredential type that was used.varcredential=error.credential;// ...});
액세스 토큰이 있으면 이를 사용하여 Facebook API를 호출할 수 있습니다.
예를 들면 다음과 같습니다.
이 로그인 방법은 또한 Facebook Login for Gaming을 IdP로 지원합니다. Identity Platform은 Facebook Login for Gaming 수동 구현을 지원하지 않습니다. Identity Platform 사용자 인증 정보 교환에 토큰만 허용합니다.
해당 개발자 문서에 나온 단계에 따라 Facebook 또는 Facebook Login for Gaming 인증을 앱에 통합합니다.
// Sign in with the credential from the user.firebase.auth().signInWithCredential(credential).then((result)=>{// Signed in// ...}).catch((error)=>{// Handle Errors here.consterrorCode=error.code;consterrorMessage=error.message;// The email of the user's account used.constemail=error.email;// ...});
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThis guide outlines the process of enabling Facebook as an identity provider within Identity Platform, including acquiring the necessary App ID and App Secret from Facebook.\u003c/p\u003e\n"],["\u003cp\u003eThe document details how to configure Facebook as a provider by setting the valid OAuth redirect URI in your Facebook app and registering your app's domains under Authorized Domains.\u003c/p\u003e\n"],["\u003cp\u003eThe process for signing in users with the client SDK using the Facebook provider object is demonstrated, offering options for both pop-up windows and page redirection, with code examples provided.\u003c/p\u003e\n"],["\u003cp\u003eFor manual sign-in, the guide explains how to integrate Facebook or Facebook Login for Gaming authentication, then exchange the received token for an Identity Platform credential to sign in users.\u003c/p\u003e\n"],["\u003cp\u003eIt is also important to know that HTTPS is required for production apps by Facebook, and using \u003ccode\u003ehttp://localhost\u003c/code\u003e for local development requires your Facebook app to be in development mode.\u003c/p\u003e\n"]]],[],null,["Signing in users with Facebook\n\nThis document shows you how to use Identity Platform to sign in users with\nFacebook.\n\nBefore you begin\n\nThis tutorial assumes you've already enabled Identity Platform, and have a\nbasic web app written using HTML and JavaScript. See the\n[Quickstart](/identity-platform/docs/sign-in-user-email) to learn how.\n\nConfiguring Facebook as a provider\n\nTo configure Facebook as an identity provider:\n\n1. Go to the **Identity Providers** page in the Google Cloud console.\n\n [Go to the Identity Providers page](https://console.cloud.google.com/customer-identity/providers)\n2. Click **Add A Provider**.\n\n3. Select **Facebook** from the list.\n\n4. Enter your Facebook **App ID** and **App Secret** . If\n you don't already have an ID and secret, you can obtain one from the\n [Facebook for Developers](https://developers.facebook.com/apps) page.\n\n5. Configure the URI listed under **Configure Facebook** as a valid OAuth\n redirect URI for your Facebook app. If you configured a custom domain in Identity Platform,\n update the redirect URI in your Facebook app configuration to use the custom domain instead\n of the default domain. For example, change `https://myproject.firebaseapp.com/__/auth/handler` to\n `https://auth.myownpersonaldomain.com/__/auth/handler`.\n\n6. Register your app's domains by clicking **Add Domain** under\n **Authorized Domains** . For development purposes, `localhost` is already\n enabled by default.\n\n | **Important:** In projects created after April 28, 2025, Identity Platform no longer includes `localhost` as an authorized domain by default. Google strongly discourages the use of `localhost` in production projects. If you choose to authorize `localhost`, you can manually add it in the **Settings** page, in **Authorized Domains** , by clicking **Add Domain**.\n7. Under **Configure your application** , click **Setup Details**. Copy the\n snippet into your app's code to initialize the Identity Platform\n client SDK.\n\n8. Click **Save**.\n\nSigning in users with the client SDK\n\n1. Create an instance of the Facebook provider object:\n\n JavaScript \n\n var provider = new firebase.auth.FacebookAuthProvider();\n\n2. **Optional:** Add OAuth scopes. Scopes specify what data you are\n requesting from Facebook. More sensitive data may require specific\n scopes. Consult the provider's\n [documentation](https://developers.facebook.com/docs/facebook-login/permissions)\n to determine what scopes your app needs.\n\n JavaScript \n\n provider.addScope('user_birthday');\n\n3. **Optional:** Localize the authentication flow. You can specify a language,\n or use the device's default language:\n\n JavaScript \n\n firebase.auth().languageCode = 'it';\n // To apply the default browser preference instead of explicitly setting it.\n // firebase.auth().useDeviceLanguage();\n\n4. **Optional:** Specify additional custom OAuth parameters. These are\n specific to Facebook, and are typically used to customize the\n authentication experience. You can't pass parameters reserved by OAuth or Identity Platform.\n\n JavaScript \n\n provider.setCustomParameters({\n 'display': 'popup'\n });\n\n5. Use the Facebook provider object to sign in the user. You can either\n open a pop-up window, or redirect the current page. Redirecting is easier\n for users on mobile devices.\n\n\n | **Note:** Facebook requires HTTPS for production apps, and does not allow login with insecure hosts. If you're developing locally using the `http://localhost` origin, ensure your Facebook app is in development mode, and that you're signing in with a registered test account.\n\n \u003cbr /\u003e\n\n To show a pop-up, call `signInWithPopup()`: \n\n JavaScript \n\n firebase\n .auth()\n .signInWithPopup(provider)\n .then((result) =\u003e {\n /** @type {firebase.auth.OAuthCredential} */\n var credential = result.credential;\n\n // The signed-in user info.\n var user = result.user;\n\n // This gives you a Facebook Access Token. You can use it to access the Facebook API.\n var accessToken = credential.accessToken;\n\n // ...\n })\n .catch((error) =\u003e {\n // Handle Errors here.\n var errorCode = error.code;\n var errorMessage = error.message;\n // The email of the user's account used.\n var email = error.email;\n // The firebase.auth.AuthCredential type that was used.\n var credential = error.credential;\n\n // ...\n });\n\n To redirect the page, first call `signInWithRedirect()`.\n\n\n Follow the [best practices](/identity-platform/docs/web/redirect-best-practices) when using `signInWithRedirect`, `linkWithRedirect`, or `reauthenticateWithRedirect`.\n\n\n JavaScript \n\n firebase.auth().signInWithRedirect(provider);\n\n Then, retrieve the Facebook token by calling `getRedirectResult()`\n when your page loads: \n\n JavaScript \n\n firebase.auth()\n .getRedirectResult()\n .then((result) =\u003e {\n if (result.credential) {\n /** @type {firebase.auth.OAuthCredential} */\n var credential = result.credential;\n\n // This gives you a Facebook Access Token. You can use it to access the Facebook API.\n var token = credential.accessToken;\n // ...\n }\n // The signed-in user info.\n var user = result.user;\n }).catch((error) =\u003e {\n // Handle Errors here.\n var errorCode = error.code;\n var errorMessage = error.message;\n // The email of the user's account used.\n var email = error.email;\n // The firebase.auth.AuthCredential type that was used.\n var credential = error.credential;\n // ...\n });\n\nOnce you have an access token, you can use it to call the Facebook API.\nFor example: \n\nREST \n\n```bash\ncurl \"https://graph.facebook.com/me?fields=id,name&access_token=[TOKEN]\"\n```\n\nSigning in users manually\n\nIf you don't want to use the client SDK, you can also handle the sign-in\nflow manually.\n\nThis sign-in method also supports Facebook Login for Gaming as\nan IdP. Identity Platform doesn't support [manually implementing Facebook Login for Gaming](https://developers.facebook.com/docs/games/social-and-retention/features/login-for-gaming#manually-implement-facebook-login-for-gaming). It only accepts the tokens for exchanging Identity Platform credentials.\n\n1. Integrate Facebook or Facebook Login for Gaming authentication into your\n app by following the steps in their developer documentation:\n\n - [Facebook developer documentation](https://developers.facebook.com/docs/facebook-login/web)\n - [Facebook Login for Gaming developer documentation](https://developers.facebook.com/docs/games/social-and-retention/features/login-for-gaming#using-facebook-sdk)\n2. Sign in the user with Facebook or Facebook Login for Gaming using the\n flow you implemented in the previous step.\n\n3. Exchange the token you receive from Facebook or Facebook Login for\n Gaming for an Identity Platform credential:\n\n JavaScript \n\n var credential = firebase.auth.FacebookAuthProvider.credential(accessToken);\n\n4. Use the credential to sign in the user with Identity Platform:\n\n JavaScript \n\n // Sign in with the credential from the user.\n firebase.auth()\n .signInWithCredential(credential)\n .then((result) =\u003e {\n // Signed in\n // ...\n })\n .catch((error) =\u003e {\n // Handle Errors here.\n const errorCode = error.code;\n const errorMessage = error.message;\n // The email of the user's account used.\n const email = error.email;\n // ...\n });\n\nWhat's next\n\n- Learn more about [Identity Platform users](/identity-platform/docs/concepts-manage-users).\n- Sign in users with [other identity providers](/identity-platform/docs/how-to#signing-in-users)."]]