ngx-auth-firebaseui icon indicating copy to clipboard operation
ngx-auth-firebaseui copied to clipboard

credential not exposed in onSuccess event

Open leandroz opened this issue 4 years ago • 3 comments

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request

Desired functionality

Currently the onSuccess event in the components only expose the user, but not the credentials. The accessToken to access additional scopes from Google (Places API, My Business API, etc) is inside credential.accessToken as shown in this example:

firebase.auth().signInWithPopup(provider).then(function(result) {
  // This gives you a Google Access Token. You can use it to access the Google API.
  var token = result.credential.accessToken;
  // The signed-in user info.
  var user = result.user;
  // ...
}).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // The email of the user's account used.
  var email = error.email;
  // The firebase.auth.AuthCredential type that was used.
  var credential = error.credential;
  // ...
});

I can send a PR but want to discuss the best solution, exposing a new event? Storing it somewhere else?

leandroz avatar Mar 29 '20 15:03 leandroz

@leandroz thanks for opening this ticket!

what's your suggestion ? a new event emitter for that ?

AnthonyNahas avatar Mar 29 '20 18:03 AnthonyNahas

I think so, unfortunately is not possible to emit multiple values from the emitter and making a change in there will be a breaking one.

One option is to add a onCredential or similar event emitter, the second option is to store the credential and expose an API to get it.

First one is super easy and quick, second one will require a lot more code.

leandroz avatar Mar 29 '20 23:03 leandroz

Oh yes @leandroz we need this! How can I help with the PR?

codercatdev avatar May 07 '20 12:05 codercatdev