I am working on introducing anonymous users to regular users through the GitHub service provider.
The idea is that in my application, users are always automatically authenticated as anonymous users. Then, when they click on the “Login using GitHub” button, basically what happens is that my application first tries to associate this anonymous user with GitHub credentials (which is basically a signal at the same time), but if the failure fails, the user already exists (for example, was previously connected), he returns to the normal character using GitHub.
I am using firebase linkWithPopup(provider)and api signInWithPopup(provider). Both methods return a promise that allows with an authenticated GitHub user, which is great! However, it turns out that the user object that I get from linkWithPopup()does not have a set of properties photoUrl. He is always null.
When I signInWithPopup()immediately, not even try to link, I also get the promise resolved with the user object, and it has a set photoUrl. So it looks like linkWithPopup()there is an error.
Is this a known issue, or is this expected behavior?
My code is as follows:
linkOrSignInWithGitHub(): Observable<User> {
let linkPromise = firebase.auth()
.currentUser
.linkWithPopup(new firebase.auth.GithubAuthProvider())
.then(result => result.user);
return Observable.fromPromise(<Promise<any>>linkPromise).catch(error => this.signInWithGitHub());
}
And signInWithGitHub()it looks like this:
signInWithGitHub(): Observable<User> {
let loginPromise = firebase.auth()
.signInWithPopup(new firebase.auth.GithubAuthProvider())
.then(result => result.user);
return Observable.fromPromise(<Promise<any>>loginPromise);
}
So, the code itself works just fine, I just don't get users photoUrlwhen using it linkWithPopup().