使用 Polymer 的 Firebase Auth 和 Google 日历

Firebase Auth and Google Calendar using Polymer

引用 ,如何使用 Polymer 元素执行此操作?

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

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

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

获得了访问令牌
gapi.auth2.getAuthInstance().currentUser.get().hg.access_token)

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

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

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

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

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

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

我在这里 找到了一个可行的解决方案,尽管我希望 firebase-auth login() 方法可以工作。作为解决方法或在出现更好的答案之前,我推荐上面的解决方案。

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