Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/Firebase.Auth/FirebaseAuthProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,22 @@ public async Task<FirebaseAuthLink> SignInWithCustomTokenAsync(string customToke
public async Task<User> GetUserAsync(string firebaseToken)
{
var content = $"{{\"idToken\":\"{firebaseToken}\"}}";
var response = await this.client.PostAsync(new Uri(string.Format(GoogleGetUser, this.authConfig.ApiKey)), new StringContent(content, Encoding.UTF8, "application/json")).ConfigureAwait(false);
var responseData = "N/A";
try
{
var response = await this.client.PostAsync(new Uri(string.Format(GoogleGetUser, this.authConfig.ApiKey)), new StringContent(content, Encoding.UTF8, "application/json")).ConfigureAwait(false);
responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
response.EnsureSuccessStatusCode();

JObject resultJson = JObject.Parse(await response.Content.ReadAsStringAsync().ConfigureAwait(false));
var user = JsonConvert.DeserializeObject<User>(resultJson["users"].First().ToString());
return user;
var resultJson = JObject.Parse(responseData);
var user = JsonConvert.DeserializeObject<User>(resultJson["users"].First().ToString());
return user;
}
catch (Exception ex)
{
AuthErrorReason errorReason = GetFailureReason(responseData);
throw new FirebaseAuthException(GoogleDeleteUserUrl, content, responseData, ex, errorReason);
}
}

/// <summary>
Expand Down