0

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?

Community
  • 1
  • 1
user3240644
  • 2,211
  • 2
  • 24
  • 35

1 Answers1

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.

Community
  • 1
  • 1
user3240644
  • 2,211
  • 2
  • 24
  • 35
  • you can also take a look here: https://github.com/MeTaNoV/firebase-element-extended – Pascal Gula Feb 05 '16 at 14:28
  • Most likely, firebase-element doesn't support [authenticating with a third party oauth token](https://www.firebase.com/docs/web/api/firebase/authwithoauthtoken.html), but simply calls authWithOAuthPopup(). Sounds like a feature request. – Kato Feb 05 '16 at 17:31
  • @PascalGula I took a quick look at github.com/MeTaNoV/firebase-element-extended but do not see how I can login with an OAuth token. – user3240644 Feb 15 '16 at 10:02