Firebase Auth and Google Calendar using Polymer

2019-09-12 06:10发布

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

On my page, I added a google-signin element

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

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)

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

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

1条回答
Viruses.
2楼-- · 2019-09-12 07:09

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.

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

查看更多
登录 后发表回答