Skip to content

Conversation

@itswisdomagain
Copy link
Contributor

Fetching user details immediately after a successful sign in is already done for SignInWithCustomTokenAsync:

public async Task<FirebaseAuthLink> SignInWithCustomTokenAsync(string customToken)
{
string content = $"{{\"token\":\"{customToken}\",\"returnSecureToken\":true}}";
FirebaseAuthLink firebaseAuthLink = await this.ExecuteWithPostContentAsync(GoogleCustomAuthUrl, content).ConfigureAwait(false);
firebaseAuthLink.User = await this.GetUserAsync(firebaseAuthLink.FirebaseToken).ConfigureAwait(false);
return firebaseAuthLink;
}

This PR adds similar functionality to other sign in methods:

  • SignInWithOAuthAsync
  • SignInWithOAuthTwitterTokenAsync
  • SignInWithGoogleIdTokenAsync
  • SignInWithGoogleIdTokenAsync
  • SignInWithEmailAndPasswordAsync

Fetching user details is not done for SignInAnonymouslyAsync as I believer each anonymous login creates a new user and there'd be no user details to fetch after such login.

Closes #21.

@Kapusch
Copy link
Contributor

Kapusch commented Apr 24, 2020

Thank you @itswisdomagain !

One question though, I've noticed this method in FirebaseAuthLink class :

public async Task RefreshUserDetails()
{
if (this.AuthProvider != null && !string.IsNullOrEmpty(this.FirebaseToken))
{
this.User = await this.AuthProvider.GetUserAsync(this.FirebaseToken).ConfigureAwait(false);
}
}

Wouldn't be good to use this instead ?

firebaseAuthLink.RefreshUserDetails(); 
@itswisdomagain
Copy link
Contributor Author

They basically do the same thing.

The approach in this PR calls this.GetUserAsync from the AuthProvider class and assigns the result to firebaseAuthLink.User.

Whereas firebaseAuthLink.RefreshUserDetails() calls AuthProvider.GetUserAsync and assigns the result to this.user.

@bezysoftware
Copy link
Collaborator

Thx for the PR, I can merge after you resolve conflicts. Also note that brand new version is being developed in V4 branch

@itswisdomagain itswisdomagain force-pushed the refresh-user-details-after-signin branch from 8d3f305 to 60a98ca Compare May 9, 2020 17:56
@itswisdomagain
Copy link
Contributor Author

@bezysoftware Merge conflicts resolved. Just a reminder.

@bezysoftware
Copy link
Collaborator

Thanks, can you also pls bump the version to 3.5.0 in the csproj? I'll deploy it to nuget then

@stale
Copy link

stale bot commented Jan 30, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 30, 2021
@itswisdomagain
Copy link
Contributor Author

Thanks, can you also pls bump the version to 3.5.0 in the csproj? I'll deploy it to nuget then

I somehow missed that comment. Will do.

@stale stale bot removed the stale label Jan 30, 2021
@bezysoftware bezysoftware merged commit f776c9f into step-up-labs:master Jan 30, 2021
@bezysoftware
Copy link
Collaborator

Published to nuget, should be available shortly, thanks!

@itswisdomagain itswisdomagain deleted the refresh-user-details-after-signin branch February 3, 2021 00:19
@EmilAlipiev
Copy link

EmilAlipiev commented Jan 3, 2022

thats not a correct implementation. especially for facebook(possibly all other social media logins twitter, instagram etc.). You will get 2 problems.

  1. firebaseAuthLink.User = await this.GetUserAsync(firebaseAuthLink.FirebaseToken).ConfigureAwait(false);
    Facebook doesnt return FirebaseToken but returns OauthAccessToken. FirebaseToken value is always null for facebook.
  2. Biger problem is Firebase doesnt store facebook or any other social media (didnt test but probably same with Twitter) user information. This method throws 400 Bad request every time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants