使用Firebase身份验证重新加载页面后获取Youtube访问令牌
我希望用户在通过Firebase登录谷歌后能够访问他们的Youtube播放列表。我使用使用Firebase身份验证重新加载页面后获取Youtube访问令牌,firebase,youtube-api,firebase-authentication,Firebase,Youtube Api,Firebase Authentication,我希望用户在通过Firebase登录谷歌后能够访问他们的Youtube播放列表。我使用firebase.auth() 问题是,如果他们刷新页面,我就无法取回他们的访问令牌。Firebase会自动再次登录,但Firebase.auth().getRedirectResult()会返回 {用户:null,凭证:未定义,操作类型:未定义} 我尝试过谷歌的方法,但我不知道从哪里获得第二步中使用的授权码 非常感谢您的帮助。Firebase不提供刷新Google访问令牌的方法。也许您最好使用Google
firebase.auth()
问题是,如果他们刷新页面,我就无法取回他们的访问令牌。Firebase会自动再次登录,但Firebase.auth().getRedirectResult()
会返回
{用户:null,凭证:未定义,操作类型:未定义}
我尝试过谷歌的方法,但我不知道从哪里获得第二步中使用的授权码
非常感谢您的帮助。Firebase不提供刷新Google访问令牌的方法。也许您最好使用Google web登录SDK来获取Google访问令牌:
它还会自动为您刷新。
然后,您可以传递Google访问令牌或ID令牌以使用Firebase登录:
firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(googleIdToken, googleAccessToken));