File tree

2 files changed

+89
-89
lines changed

2 files changed

+89
-89
lines changed
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ public enum AuthErrorReason
66
/// Unknown error reason.
77
/// </summary>
88
Undefined,
9-
/// <summary>
10-
/// The sign in method is not enabled.
11-
/// </summary>
12-
OperationNotAllowed,
13-
/// <summary>
14-
/// The user was disabled and is not granted access anymore.
15-
/// </summary>
16-
UserDisabled,
9+
/// <summary>
10+
/// The sign in method is not enabled.
11+
/// </summary>
12+
OperationNotAllowed,
13+
/// <summary>
14+
/// The user was disabled and is not granted access anymore.
15+
/// </summary>
16+
UserDisabled,
1717
/// <summary>
1818
/// The user was not found
1919
/// </summary>
@@ -66,22 +66,22 @@ public enum AuthErrorReason
6666
/// Email/Password Signin: The supplied password is not valid for the email address.
6767
/// </summary>
6868
WrongPassword,
69-
/// <summary>
70-
/// Email/Password Signin: Too many password login have been attempted. Try again later.
71-
/// </summary>
72-
TooManyAttemptsTryLater,
73-
/// <summary>
74-
/// Password Recovery: Request does not contain a value for parameter: requestType or supplied value is invalid.
75-
/// </summary>
76-
MissingRequestType,
77-
/// <summary>
78-
/// Password Recovery: Reset password limit exceeded.
79-
/// </summary>
80-
ResetPasswordExceedLimit,
81-
/// <summary>
82-
/// Account Linking: Authenticated User ID Token is invalid!
83-
/// </summary>
84-
InvalidIDToken,
69+
/// <summary>
70+
/// Email/Password Signin: Too many password login have been attempted. Try again later.
71+
/// </summary>
72+
TooManyAttemptsTryLater,
73+
/// <summary>
74+
/// Password Recovery: Request does not contain a value for parameter: requestType or supplied value is invalid.
75+
/// </summary>
76+
MissingRequestType,
77+
/// <summary>
78+
/// Password Recovery: Reset password limit exceeded.
79+
/// </summary>
80+
ResetPasswordExceedLimit,
81+
/// <summary>
82+
/// Account Linking: Authenticated User ID Token is invalid!
83+
/// </summary>
84+
InvalidIDToken,
8585
/// <summary>
8686
/// Linked Accounts: Request does not contain a value for parameter: identifier.
8787
/// </summary>
@@ -94,5 +94,5 @@ public enum AuthErrorReason
9494
/// Linked accounts: account to link has already been linked.
9595
/// </summary>
9696
AlreadyLinked
97-
}
97+
}
9898
}
Original file line numberDiff line numberDiff line change
@@ -105,40 +105,40 @@ public async Task<FirebaseAuthLink> SignInWithOAuthAsync(FirebaseAuthType authTy
105105
return await this.ExecuteWithPostContentAsync(GoogleIdentityUrl, content).ConfigureAwait(false);
106106
}
107107

108-
/// <summary>
109-
/// Using the provided Id token from google signin, get the firebase auth with token and basic user credentials.
110-
/// </summary>
111-
/// <param name="authType"> The auth type. </param>
112-
/// <param name="oauthAccessToken"> The access token retrieved from twitter. </param>
113-
/// <param name="oauthAccessToken"> The access token secret supplied by twitter. </param>
114-
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
115-
public async Task<FirebaseAuthLink> SignInWithOAuthTwitterTokenAsync(string oauthAccessToken, string oauthTokenSecret)
116-
{
117-
var providerId = this.GetProviderId(FirebaseAuthType.Twitter);
118-
var content = $"{{\"postBody\":\"access_token={oauthAccessToken}&oauth_token_secret={oauthTokenSecret}&providerId={providerId}\",\"requestUri\":\"http://localhost\",\"returnSecureToken\":true}}";
119-
120-
return await this.ExecuteWithPostContentAsync(GoogleIdentityUrl, content).ConfigureAwait(false);
121-
}
122-
123-
/// <summary>
124-
/// Using the provided Id token from google signin, get the firebase auth with token and basic user credentials.
125-
/// </summary>
126-
/// <param name="authType"> The auth type. </param>
127-
/// <param name="idToken"> The Id token retrieved from google signin </param>
128-
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
129-
public async Task<FirebaseAuthLink> SignInWithGoogleIdTokenAsync(string idToken)
108+
/// <summary>
109+
/// Using the provided Id token from google signin, get the firebase auth with token and basic user credentials.
110+
/// </summary>
111+
/// <param name="authType"> The auth type. </param>
112+
/// <param name="oauthAccessToken"> The access token retrieved from twitter. </param>
113+
/// <param name="oauthAccessToken"> The access token secret supplied by twitter. </param>
114+
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
115+
public async Task<FirebaseAuthLink> SignInWithOAuthTwitterTokenAsync(string oauthAccessToken, string oauthTokenSecret)
116+
{
117+
var providerId = this.GetProviderId(FirebaseAuthType.Twitter);
118+
var content = $"{{\"postBody\":\"access_token={oauthAccessToken}&oauth_token_secret={oauthTokenSecret}&providerId={providerId}\",\"requestUri\":\"http://localhost\",\"returnSecureToken\":true}}";
119+
120+
return await this.ExecuteWithPostContentAsync(GoogleIdentityUrl, content).ConfigureAwait(false);
121+
}
122+
123+
/// <summary>
124+
/// Using the provided Id token from google signin, get the firebase auth with token and basic user credentials.
125+
/// </summary>
126+
/// <param name="authType"> The auth type. </param>
127+
/// <param name="idToken"> The Id token retrieved from google signin </param>
128+
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
129+
public async Task<FirebaseAuthLink> SignInWithGoogleIdTokenAsync(string idToken)
130130
{
131131
var providerId = this.GetProviderId(FirebaseAuthType.Google);
132132
var content = $"{{\"postBody\":\"id_token={idToken}&providerId={providerId}\",\"requestUri\":\"http://localhost\",\"returnSecureToken\":true}}";
133133

134134
return await this.ExecuteWithPostContentAsync(GoogleIdentityUrl, content).ConfigureAwait(false);
135-
}
135+
}
136136

137-
/// <summary>
138-
/// Sign in user anonymously. He would still have a user id and access token generated, but name and other personal user properties will be null.
139-
/// </summary>
140-
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
141-
public async Task<FirebaseAuthLink> SignInAnonymouslyAsync()
137+
/// <summary>
138+
/// Sign in user anonymously. He would still have a user id and access token generated, but name and other personal user properties will be null.
139+
/// </summary>
140+
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
141+
public async Task<FirebaseAuthLink> SignInAnonymouslyAsync()
142142
{
143143
var content = $"{{\"returnSecureToken\":true}}";
144144

@@ -278,21 +278,21 @@ public async Task DeleteUserAsync(string firebaseToken)
278278
public async Task SendPasswordResetEmailAsync(string email)
279279
{
280280
var content = $"{{\"requestType\":\"PASSWORD_RESET\",\"email\":\"{email}\"}}";
281-
var responseData = "N/A";
282-
283-
try
284-
{
285-
var response = await this.client.PostAsync(new Uri(string.Format(GoogleGetConfirmationCodeUrl, this.authConfig.ApiKey)), new StringContent(content, Encoding.UTF8, "application/json")).ConfigureAwait(false);
286-
responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
287-
288-
response.EnsureSuccessStatusCode();
289-
}
290-
catch (Exception ex)
291-
{
292-
AuthErrorReason errorReason = GetFailureReason(responseData);
293-
throw new FirebaseAuthException(GoogleGetConfirmationCodeUrl, content, responseData, ex, errorReason);
294-
}
295-
}
281+
var responseData = "N/A";
282+
283+
try
284+
{
285+
var response = await this.client.PostAsync(new Uri(string.Format(GoogleGetConfirmationCodeUrl, this.authConfig.ApiKey)), new StringContent(content, Encoding.UTF8, "application/json")).ConfigureAwait(false);
286+
responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
287+
288+
response.EnsureSuccessStatusCode();
289+
}
290+
catch (Exception ex)
291+
{
292+
AuthErrorReason errorReason = GetFailureReason(responseData);
293+
throw new FirebaseAuthException(GoogleGetConfirmationCodeUrl, content, responseData, ex, errorReason);
294+
}
295+
}
296296

297297
/// <summary>
298298
/// Sends user an email with a link to verify his email address.
@@ -519,12 +519,12 @@ private static AuthErrorReason GetFailureReason(string responseData)
519519
failureReason = AuthErrorReason.LoginCredentialsTooOld;
520520
break;
521521

522-
case "OPERATION_NOT_ALLOWED":
523-
failureReason = AuthErrorReason.OperationNotAllowed;
524-
break;
522+
case "OPERATION_NOT_ALLOWED":
523+
failureReason = AuthErrorReason.OperationNotAllowed;
524+
break;
525525

526-
//possible errors from Third Party Authentication using GoogleIdentityUrl
527-
case "INVALID_PROVIDER_ID : Provider Id is not supported.":
526+
//possible errors from Third Party Authentication using GoogleIdentityUrl
527+
case "INVALID_PROVIDER_ID : Provider Id is not supported.":
528528
failureReason = AuthErrorReason.InvalidProviderID;
529529
break;
530530
case "MISSING_REQUEST_URI":
@@ -540,9 +540,9 @@ private static AuthErrorReason GetFailureReason(string responseData)
540540
break;
541541
case "MISSING_PASSWORD":
542542
failureReason = AuthErrorReason.MissingPassword;
543-
break;
543+
break;
544544

545-
//possible errors from Email/Password Account Signup (via signupNewUser or setAccountInfo)
545+
//possible errors from Email/Password Account Signup (via signupNewUser or setAccountInfo)
546546
case "EMAIL_EXISTS":
547547
failureReason = AuthErrorReason.EmailExists;
548548
break;
@@ -563,16 +563,16 @@ private static AuthErrorReason GetFailureReason(string responseData)
563563
failureReason = AuthErrorReason.UserDisabled;
564564
break;
565565

566-
//possible errors from Email/Password Signin or Password Recovery or Email/Password Sign up using setAccountInfo
567-
case "MISSING_EMAIL":
566+
//possible errors from Email/Password Signin or Password Recovery or Email/Password Sign up using setAccountInfo
567+
case "MISSING_EMAIL":
568568
failureReason = AuthErrorReason.MissingEmail;
569569
break;
570-
case "RESET_PASSWORD_EXCEED_LIMIT":
571-
failureReason = AuthErrorReason.ResetPasswordExceedLimit;
572-
break;
570+
case "RESET_PASSWORD_EXCEED_LIMIT":
571+
failureReason = AuthErrorReason.ResetPasswordExceedLimit;
572+
break;
573573

574-
//possible errors from Password Recovery
575-
case "MISSING_REQ_TYPE":
574+
//possible errors from Password Recovery
575+
case "MISSING_REQ_TYPE":
576576
failureReason = AuthErrorReason.MissingRequestType;
577577
break;
578578

@@ -593,13 +593,13 @@ private static AuthErrorReason GetFailureReason(string responseData)
593593
break;
594594
}
595595

596-
if(failureReason == AuthErrorReason.Undefined)
597-
{
598-
//possible errors from Email/Password Account Signup (via signupNewUser or setAccountInfo)
599-
if(errorData?.error?.message?.StartsWith("WEAK_PASSWORD :") ?? false) failureReason = AuthErrorReason.WeakPassword;
600-
//possible errors from Email/Password Signin
601-
else if (errorData?.error?.message?.StartsWith("TOO_MANY_ATTEMPTS_TRY_LATER :") ?? false) failureReason = AuthErrorReason.TooManyAttemptsTryLater;
602-
}
596+
if(failureReason == AuthErrorReason.Undefined)
597+
{
598+
//possible errors from Email/Password Account Signup (via signupNewUser or setAccountInfo)
599+
if(errorData?.error?.message?.StartsWith("WEAK_PASSWORD :") ?? false) failureReason = AuthErrorReason.WeakPassword;
600+
//possible errors from Email/Password Signin
601+
else if (errorData?.error?.message?.StartsWith("TOO_MANY_ATTEMPTS_TRY_LATER :") ?? false) failureReason = AuthErrorReason.TooManyAttemptsTryLater;
602+
}
603603
}
604604
}
605605
catch (JsonReaderException)

0 commit comments

Comments
 (0)