@@ -105,40 +105,40 @@ public async Task<FirebaseAuthLink> SignInWithOAuthAsync(FirebaseAuthType authTy
105
105
return await this . ExecuteWithPostContentAsync ( GoogleIdentityUrl , content ) . ConfigureAwait ( false ) ;
106
106
}
107
107
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 )
130
130
{
131
131
var providerId = this . GetProviderId ( FirebaseAuthType . Google ) ;
132
132
var content = $ "{{\" postBody\" :\" id_token={ idToken } &providerId={ providerId } \" ,\" requestUri\" :\" http://localhost\" ,\" returnSecureToken\" :true}}";
133
133
134
134
return await this . ExecuteWithPostContentAsync ( GoogleIdentityUrl , content ) . ConfigureAwait ( false ) ;
135
- }
135
+ }
136
136
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 ( )
142
142
{
143
143
var content = $ "{{\" returnSecureToken\" :true}}";
144
144
@@ -278,21 +278,21 @@ public async Task DeleteUserAsync(string firebaseToken)
278
278
public async Task SendPasswordResetEmailAsync ( string email )
279
279
{
280
280
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
+ }
296
296
297
297
/// <summary>
298
298
/// Sends user an email with a link to verify his email address.
@@ -519,12 +519,12 @@ private static AuthErrorReason GetFailureReason(string responseData)
519
519
failureReason = AuthErrorReason . LoginCredentialsTooOld ;
520
520
break ;
521
521
522
- case "OPERATION_NOT_ALLOWED" :
523
- failureReason = AuthErrorReason . OperationNotAllowed ;
524
- break ;
522
+ case "OPERATION_NOT_ALLOWED" :
523
+ failureReason = AuthErrorReason . OperationNotAllowed ;
524
+ break ;
525
525
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." :
528
528
failureReason = AuthErrorReason . InvalidProviderID ;
529
529
break ;
530
530
case "MISSING_REQUEST_URI" :
@@ -540,9 +540,9 @@ private static AuthErrorReason GetFailureReason(string responseData)
540
540
break ;
541
541
case "MISSING_PASSWORD" :
542
542
failureReason = AuthErrorReason . MissingPassword ;
543
- break ;
543
+ break ;
544
544
545
- //possible errors from Email/Password Account Signup (via signupNewUser or setAccountInfo)
545
+ //possible errors from Email/Password Account Signup (via signupNewUser or setAccountInfo)
546
546
case "EMAIL_EXISTS" :
547
547
failureReason = AuthErrorReason . EmailExists ;
548
548
break ;
@@ -563,16 +563,16 @@ private static AuthErrorReason GetFailureReason(string responseData)
563
563
failureReason = AuthErrorReason . UserDisabled ;
564
564
break ;
565
565
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" :
568
568
failureReason = AuthErrorReason . MissingEmail ;
569
569
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 ;
573
573
574
- //possible errors from Password Recovery
575
- case "MISSING_REQ_TYPE" :
574
+ //possible errors from Password Recovery
575
+ case "MISSING_REQ_TYPE" :
576
576
failureReason = AuthErrorReason . MissingRequestType ;
577
577
break ;
578
578
@@ -593,13 +593,13 @@ private static AuthErrorReason GetFailureReason(string responseData)
593
593
break ;
594
594
}
595
595
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
+ }
603
603
}
604
604
}
605
605
catch ( JsonReaderException )
0 commit comments