Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35: Add <firebase-auth> support for custom token auth #41

Merged
merged 1 commit into from
Jun 23, 2016
Merged

Fixes #35: Add <firebase-auth> support for custom token auth #41

merged 1 commit into from
Jun 23, 2016

Conversation

sgammon
Copy link
Contributor

@sgammon sgammon commented Jun 10, 2016

This changeset adds a simple function to support signInWithCustomToken in the <firebase-auth> component.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@sgammon
Copy link
Contributor Author

sgammon commented Jun 10, 2016

I signed it!

@sgammon
Copy link
Contributor Author

sgammon commented Jun 10, 2016

It is a corp CLA under the name Momentum Ideas Co.

return Promise.reject('No app configured for firebase-auth!');
}
return this._handleSignIn(this.auth.signInWithCustomToken(token));
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woop,
there it is

@safizn
Copy link

safizn commented Jun 15, 2016

Thanks man ! This is a must feature. Wondering why it wasn't included in the release.

@unusec
Copy link

unusec commented Jun 19, 2016

Just fund this after I spent some time to create this on my own, this should be merged asap.

@mbleigh
Copy link
Contributor

mbleigh commented Jun 23, 2016

Great! Thanks for the PR.

@mbleigh mbleigh merged commit 8a9d9b4 into FirebaseExtended:master Jun 23, 2016
@safizn
Copy link

safizn commented Jun 23, 2016

@mbleigh @sgammon Thanks for merging it. I cannot figure out how to use it.

I'm getting the following error:
POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=KEY 400 ()
page.php:903 my custom error message.
firebase.js:75 Uncaught Error: The custom token format is incorrect. Please check the documentation.

Please provide a simple example. This is what I'm currently using:
<firebase-app name="app" api-key="APIKEY" auth-domain="XXX.firebaseapp.com" database-url="https://XXX.firebaseio.com" ></firebase-app>
<firebase-auth id="auth" app-name="app" provider="custom" on-error="_handleAuthError" ></firebase-auth>
<firebase-query id="query" app-name="app" path="/path/subpath" data="{{data}}" ></firebase-query>
...
ready: function() { this.$.auth.signInWithCustomToken('KEY'); },

@sgammon
Copy link
Contributor Author

sgammon commented Jun 23, 2016

well you will probably need a better key than 'KEY'... lol

but I digress, Firebase's custom token format has changed. so if you are generating tokens in the old 2.x format (we were), you will have to switch over to their new token generator library.

see here for code samples in Java and Node.JS:
https://firebase.google.com/docs/auth/server#create_a_custom_token

basically they changed the token format so that all the developer-provided claims are listed in a claims hash. the JWT is also now signed with your service account's private key, instead of the simple Firebase secret like before.

@safizn
Copy link

safizn commented Jun 23, 2016

Oh didn't know that. I was actually using the old tokens. Generating them with the old PHP SDK for the server.
That would be the problem then. Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants