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

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

问题描述

我使用以下代码(Angularfire2)在Google登录身份验证中授权了日历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天全站免登陆