Firebase 身份验证后访问范围数据 [英] Access scope data after Firebase authentication

查看:32
本文介绍了Firebase 身份验证后访问范围数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码 (Angularfire2) 在我的谷歌登录身份验证中授权了日历 API:

I authorized the calendar api in my google sign in auth, using the following code (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 访问授权范围?

Is there any way to access authorized scopes using FirebaseAuth?

例如,在用户签署日历授权后访问日历数据.

For example, access the calendar data after the user signs and authorizes the calendar auth.

推荐答案

如果您查看 参考文档,您会看到有示例对于每个提供者,演示了如何获取第三方 OAuth 令牌:

If you check out the reference docs, you'll see that there are examples for each provider, which demonstrate how to obtain the third-party OAuth token:

// 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.

Once you have the third-party token, you can use that directly against their APIs.

这篇关于Firebase 身份验证后访问范围数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆