Skip to content

Commit 62a59f2

Browse files
authored
Merge pull request #72 from cabauman/colt_googleIdToken
Add method to sign in with Google ID token
2 parents 90becb8 + 1824e34 commit 62a59f2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Firebase.Auth/FirebaseAuthProvider.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ public async Task<FirebaseAuthLink> SignInWithOAuthAsync(FirebaseAuthType authTy
8989
return await this.ExecuteWithPostContentAsync(GoogleIdentityUrl, content).ConfigureAwait(false);
9090
}
9191

92+
/// <summary>
93+
/// Using the provided Id token from google signin, get the firebase auth with token and basic user credentials.
94+
/// </summary>
95+
/// <param name="authType"> The auth type. </param>
96+
/// <param name="idToken"> The Id token retrieved from google signin </param>
97+
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
98+
public async Task<FirebaseAuthLink> SignInWithGoogleIdTokenAsync(string idToken)
99+
{
100+
var providerId = this.GetProviderId(FirebaseAuthType.Google);
101+
var content = $"{{\"postBody\":\"id_token={idToken}&providerId={providerId}\",\"requestUri\":\"http://localhost\",\"returnSecureToken\":true}}";
102+
103+
return await this.ExecuteWithPostContentAsync(GoogleIdentityUrl, content).ConfigureAwait(false);
104+
}
105+
92106
/// <summary>
93107
/// 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.
94108
/// </summary>

0 commit comments

Comments
 (0)