0

signInWithPopup() 대신 signInWithCredential()을 어떻게 사용할 수 있습니까? signInWithPopup이 내 휴대 전화 Google 크롬 브라우저에서 작동하지 않고 주변을 살펴본 결과 알려진 문제이며 대신 signInWithCredential()을 사용함을 알았습니다. 그러나 내가 작동하지 않는 것 같아, 내 현재 코드 signInWithPopup()을 사용하여 다음과 같습니다. 어떤 종류의 영혼이 나를 도울 수 있습니까? signInWithCredential를 사용하려면 감사Google이 firebase로 로그인

login() { 
    return new Promise((resolve) => { 
     this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider()).then(() => { 
     this.afAuth.authState.take(1).subscribe(async (authState) => { 
      resolve(authState); 
     }); 
     }); 
    }); 
    } 
+0

당신이 말하는이 알려진 문제는 무엇입니까? – bojeil

답변

0

, 당신은 OAuth는 ID 토큰/액세스 토큰을 가진 AuthCredential를 초기화해야합니다. 예를 들어 는 : https://developers.google.com/identity/sign-in/web/sign-in

이는 브라우저에서 작동합니다

const cred = firebase.auth.GoogleAuthProvider.credential(googleIdToken, googleAccessToken); 
firebase.auth().signInAndRetrieveDataWithCredential(cred) 
    .then(userCredential => { 
    // Success. 
    }) 
    .catch(error => { 
    // error occurred. 
    }); 

당신은 구글 ID 토큰을 얻기 위해 라이브러리에있는 구글 기호를 사용할 수 있습니다. 다른 브라우저가 아닌 환경에서 이것을 사용하는 경우 해당 OAuth 자격 증명을 얻으려면 타사 OAuth 라이브러리가 필요합니다.