问题
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:
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.
来源:https://stackoverflow.com/questions/35195782/firebase-auth-and-google-calendar-using-polymer