Firebase 身份验证后访问范围数据
Access scope data after Firebase authentication
我在我的 google 登录身份验证中授权了日历 api,使用以下代码 (Angularfire2):
let auth = new firebase.auth.GoogleAuthProvider();
auth.addScope('https://www.googleapis.com/auth/calendar');
this.afAuth.auth
.signInWithPopup(auth).then((data) => {
console.log(data); // nothing about calendar here
});
是否有任何方法可以使用 FirebaseAuth 访问授权范围?
例如,用户在日历auth上签名授权后访问日历数据
如果您查看reference docs, you'll see that there are examples for each provider,它演示了如何获取第三方 OAuth 令牌:
// Using a redirect.
firebase.auth().getRedirectResult().then(function(result) {
if (result.credential) {
// This gives you a Google Access Token.
var token = result.credential.accessToken;
}
var user = result.user;
});
获得第三方令牌后,您可以直接将其用于他们的 API。
我在我的 google 登录身份验证中授权了日历 api,使用以下代码 (Angularfire2):
let auth = new firebase.auth.GoogleAuthProvider();
auth.addScope('https://www.googleapis.com/auth/calendar');
this.afAuth.auth
.signInWithPopup(auth).then((data) => {
console.log(data); // nothing about calendar here
});
是否有任何方法可以使用 FirebaseAuth 访问授权范围?
例如,用户在日历auth上签名授权后访问日历数据
如果您查看reference docs, you'll see that there are examples for each provider,它演示了如何获取第三方 OAuth 令牌:
// Using a redirect.
firebase.auth().getRedirectResult().then(function(result) {
if (result.credential) {
// This gives you a Google Access Token.
var token = result.credential.accessToken;
}
var user = result.user;
});
获得第三方令牌后,您可以直接将其用于他们的 API。