0Pricing
Firebase Auth & Realtime Database Apps · 강의

Facebook 및 GitHub 인증

Facebook과 GitHub를 인증 제공자로 추가하고, 소셜 로그인을 위해 앱과 Firebase를 구성합니다.

Facebook 및 GitHub 인증은(는) CoddyKit의 무료 Firebase Auth & Realtime Database Apps 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Firebase Auth & Realtime Database Apps 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Firebase Auth & Realtime Database Apps 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Social Logins: Facebook & GitHub

Welcome! In this lesson, we'll dive into integrating two popular social login options: Facebook and GitHub.

Using social providers like these can significantly improve the user experience by offering quick, familiar sign-up and login methods.

Why Offer Social Logins?

Social logins provide a seamless experience for your users. Here's why they're great:

  • Convenience: Users can sign in with accounts they already have.
  • Reduced Friction: No need to create new usernames or passwords.
  • Trust: Users often feel more secure using established platforms.
  • Faster Onboarding: Quick access to your app's features.

Facebook App Setup: Developer Console

Before enabling Facebook login in Firebase, you need to create an app on the Facebook for Developers platform.

  • Go to developers.facebook.com and create a new app.
  • Choose the 'Consumer' type for typical user authentication.
  • Note down your App ID and App Secret; you'll need them for Firebase.

Facebook Login Product Configuration

After creating your Facebook app, you must configure the 'Facebook Login' product:

  • In your Facebook App Dashboard, add the 'Facebook Login' product.
  • Under 'Settings' for Facebook Login, ensure 'Web OAuth Login' is enabled.
  • Add your Firebase OAuth redirect URI (found in Firebase Auth settings) to 'Valid OAuth Redirect URIs'. This is crucial for security.

Firebase Console: Enable Facebook

Now, let's enable Facebook as an authentication provider in Firebase:

  1. Navigate to the Authentication section in your Firebase project console.
  2. Go to the 'Sign-in method' tab.
  3. Click 'Add new provider' and select Facebook.
  4. Paste your Facebook App ID and App Secret into the fields provided.
  5. Make sure to enable the provider and save your changes!

Code: Facebook Sign-In

Once configured, you can use the Firebase SDK to sign in users with Facebook. This JavaScript example shows the core logic, typically triggered by a button.

/* This is a conceptual example for web/JS.
   Firebase SDK must be initialized before use. */

// 1. Get Auth instance & Facebook provider
const auth = firebase.auth();
const provider = new firebase.auth.FacebookAuthProvider();

// 2. Define the sign-in function
function signInWithFacebook() {
  console.log("Attempting Facebook sign-in...");
  auth.signInWithPopup(provider)
    .then((result) => {
      // User successfully signed in
      const user = result.user;
      console.log("Logged in as:", user.displayName);
    })
    .catch((error) => {
      // Handle errors (e.g., user cancelled, network error)
      console.error("Facebook login failed:", error.message);
    });
}

// Call the function (in a real app, this is a button click)
signInWithFacebook();

GitHub App Setup: Developer Console

Integrating GitHub is similar to Facebook. First, you need to create an OAuth App on GitHub:

  • Go to github.com/settings/developers.
  • Click 'New OAuth App'.
  • Fill in the 'Application name', 'Homepage URL'.
  • For 'Authorization callback URL', use your Firebase OAuth redirect URI.
  • Click 'Register application' and note your Client ID and Client Secret.

Firebase Console: Enable GitHub

Next, enable GitHub as an authentication provider in your Firebase project:

  1. In the Firebase console, go to Authentication > Sign-in method.
  2. Click 'Add new provider' and select GitHub.
  3. Paste your GitHub Client ID and Client Secret into the respective fields.
  4. Enable the provider and save your changes.

The Firebase OAuth redirect URI for GitHub will be displayed here, ensure it matches what you entered on GitHub.

Code: GitHub Sign-In

Just like Facebook, once GitHub is configured, you can use the Firebase SDK to sign in users. This JavaScript snippet illustrates the process.

/* This is a conceptual example for web/JS.
   Firebase SDK must be initialized before use. */

// 1. Get Auth instance & GitHub provider
const auth = firebase.auth();
const provider = new firebase.auth.GithubAuthProvider();

// 2. Define the sign-in function
function signInWithGitHub() {
  console.log("Attempting GitHub sign-in...");
  auth.signInWithPopup(provider)
    .then((result) => {
      // User successfully signed in
      const user = result.user;
      console.log("Logged in as:", user.displayName);
    })
    .catch((error) => {
      // Handle errors (e.g., user cancelled, network error)
      console.error("GitHub login failed:", error.message);
    });
}

// Call the function (in a real app, this is a button click)
signInWithGitHub();

Quick Check: Social Login Setup

You've learned the steps to integrate social logins. Which of these are essential for setting up a new social authentication provider (like Facebook or GitHub) with Firebase?

Recap: Facebook & GitHub Auth

Great job! In this lesson, you learned how to add Facebook and GitHub authentication to your Firebase project.

  • We covered creating developer apps on each platform.
  • You saw how to configure the necessary settings, including OAuth redirect URIs.
  • Finally, we enabled these providers in the Firebase console and looked at conceptual code for signing users in.

Social logins simplify user onboarding and enhance your app's accessibility!

자주 묻는 질문

“Facebook 및 GitHub 인증” 강의는 무료인가요?

네 — “Facebook 및 GitHub 인증” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Firebase Auth & Realtime Database Apps 강의 전체를 잠금 해제할 수 있습니다. Firebase Auth & Realtime Database Apps 강의에는 총 4개의 강의가 포함되어 있습니다.

“Facebook 및 GitHub 인증”에서 뭘 배우나요?

Facebook과 GitHub를 인증 제공자로 추가하고, 소셜 로그인을 위해 앱과 Firebase를 구성합니다. 브라우저에서 직접 실행하는 실습 코드로 Firebase Auth & Realtime Database Apps을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Firebase Auth & Realtime Database Apps을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Firebase Auth & Realtime Database Apps은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“Facebook 및 GitHub 인증” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Firebase Auth & Realtime Database Apps 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Firebase Auth & Realtime Database Apps 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Google 로그인 통합
  2. Facebook 및 GitHub 인증
  3. 익명 인증 및 사용자 지정 인증
  4. Apple 로그인 연동
← Firebase Auth & Realtime Database Apps(으)로 돌아가기