учетные данные
база: {firebase.auth.authcredential}
token: "eyjhbgcioijsuzi1niisimt…"
tokentype: firebase.auth.providers.oauthcredentialtokentype.accesstoken < /p>
Используя этот код: < /p>
Код: Выделить всё
if (requestCode == RC_SIGN_IN)
{
var task = GoogleSignIn.GetSignedInAccountFromIntent(data);
if (!task.IsSuccessful)
{
Console.WriteLine($"Google Sign-In failed. Exception: {task.Exception}");
return;
}
var account = task.Result as GoogleSignInAccount;
// Check if the IdToken is available
if (!string.IsNullOrEmpty(account?.IdToken))
{
string idToken = account.IdToken;
Console.WriteLine($"AccessToken: {account?.ServerAuthCode}"); // Access token
Console.WriteLine($"IdToken: {account?.IdToken}"); // ID token
Console.WriteLine($"IdToken: {idToken}");
//OnGoogleSignInCompleted?.Invoke(idToken);
SignInWithFirebase(idToken);
}
else
{
Console.WriteLine("IdToken is missing. Check your GoogleSignInOptions configuration.");
OnGoogleSignInCompleted?.Invoke(null);
}
}
var userCredential = await authClient.SignInWithCredentialAsync(credential);
Полный код ниже:
Код: Выделить всё
private async void SignInWithFirebase(string idToken)
{
try
{
Console.WriteLine("Starting Firebase Sign-In...");
// Create the credential with the IdToken
var credential = GoogleProvider.GetCredential(idToken);
Console.WriteLine("Firebase Credential created.");
// Initialize Firebase Auth Client
var authClient = new FirebaseAuthClient(new FirebaseAuthConfig
{
ApiKey = "MY_KEY",
AuthDomain = "MY_DOMAIN",
Providers = new FirebaseAuthProvider[]
{
new GoogleProvider()
}
});
Console.WriteLine("Firebase Auth Client initialized.");
// Sign in with the credential
var userCredential = await authClient.SignInWithCredentialAsync(credential);
Console.WriteLine($"User signed in: {userCredential.User.Info.DisplayName} ({userCredential.User.Info.Email})");
}
catch (Exception ex)
{
Console.WriteLine($"Firebase Sign-In failed: {ex.Message}");
Console.WriteLine($"Stack Trace: {ex.StackTrace}");
}
}
[dotnet] Firebase Fover Faste: Исключение произошло во время запроса Firebase HTTP.
[Dotnet] url: https://www.googleapis.com/identitytool ... ion?key=my Key
[dotnet] Запрос данных: {"requesturi": "https: // mydomain, «Postbody»: «access_token = eyjhbgcioijsuzi1niisimtpzci6ijy ...
[dotnet]" Сообщение ":" Invalid_idp_response: unduccesscipbure проверить проверку от ответа на Google: {
"error_descript
",
[dotnet]" ошибки ": [
[dotnet] {
[dotnet]" message ":" Invalid_idp_response: безуспешно проверить ответ авторизации от Google: {
"error_description": "неверное значение"
}
",
[dotnet]" domain ":" global ",
[dotnet]" Причина ":" Invalid "
Подробнее здесь: https://stackoverflow.com/questions/793 ... synccreden
Мобильная версия