使用Polymer的Firebase Auth和Google日历 [英] Firebase Auth and Google Calendar using Polymer

查看:106
本文介绍了使用Polymer的Firebase Auth和Google日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考 Firebase Auth和Google日历,我该如何使用Polymer元素执行此操作?

Referencing Firebase Auth and Google Calendar, how do I do this with Polymer elements?

在页面上,我添加了一个google-signin元素

On my page, I added a google-signin element

<google-signin
   client-id="xxxx.apps.googleusercontent.com">
</google-signin>

然后我等待google-signin-success事件被触发并使用

I then waited for the google-signin-success event to be fired and got the access token with

gapi.auth2.getAuthInstance().currentUser.get().hg.access_token)

如何使用firebase-auth登录?我尝试在页面中像这样添加firebase-auth元素

How do I login with firebase-auth? I tried adding the firebase-auth element like so in my page

<firebase-auth id="authenticate"
               user="{{user}}"
               location="{{location}}"
               ref="{{refauth}}"
               provider="google">
</firebase-auth>

并像这样以编程方式调用它

and called it programmatically like so

  signIn: function() {
    var params = {token: "ya29.xxxxx"};
    this.$.authenticate.login(params);
  },

  signOut: function() {
    this.$.authenticate.logout();
    this.user = null;
  }
});

但是,firebase-auth仍会弹出一个Google登录对话框.如何使用访问令牌登录?

however, firebase-auth would still pop up a google signin dialog. How do I login with the access token?

推荐答案

我在这里

I found a working solution here Authenticate Firebase in Polymer using OAuth token although I expected firebase-auth login() method to work. As a workaround or till a better answer comes along, I'd recommend the solution above.

更新: firebase-element的修订版1.0.12现在支持使用OAuth令牌的无头登录.

Update: Rev 1.0.12 of firebase-element now supports headless login using OAuth token.

这篇关于使用Polymer的Firebase Auth和Google日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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