Authenticate Using Google with JavaScript
자바스크립트로 Google을 사용하여 인증 | Firebase
Google은 흑인 공동체를 위한 인종적 평등을 추구하기 위해 노력하고 있습니다. 자세히 알아보기 의견 보내기 자바스크립트로 Google을 사용하여 인증 알림 이 페이지를 개발자 프로필에 저장하여
firebase.google.com
Create an instance of the Google provider object
import { GoogleAuthProvider } from "firebase/auth";
const provider = new GoogleAuthProvider();
Authenticate with Firebase using the Google provider object. You can prompt your users to sign in with their Google Accounts either by opening a pop-up window or by redirecting to the sign-in page. The redirect method is preferred on mobile devices.
To sign in with a pop-up window, call signInWithPopup:
import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth";
const auth = getAuth();
signInWithPopup(auth, provider)
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
// The signed-in user info.
const user = result.user;
// ...
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
});
Firebase -> Console -> Authentication -> Users
에서 사용자가 생겼는지 확인
'Others' 카테고리의 다른 글
쿠키, 세션, 토큰, JWT (0) | 2022.11.07 |
---|---|
웹 브라우저는 어떻게 작동 될까? (0) | 2022.11.07 |
4개월 부트캠프 회고 | 나는 어떻게 개발자로 성장하였는가 (0) | 2022.08.28 |
부트캠프를 마치며: 미리 알았더라면 좋았던 것들 (0) | 2022.08.26 |
Github 자주쓰는 명령어 (0) | 2022.08.25 |