Access scope data after Firebase authentication

女生的网名这么多〃 提交于 2019-12-22 09:28:29

问题


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
      });

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.


回答1:


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;
});

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



来源:https://stackoverflow.com/questions/44476822/access-scope-data-after-firebase-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!