Насколько я знаю, методу GoogleAuthProvider.GetCredential требуется Idtoken, который генерируется при входе пользователя в веб-браузер.
Но в Unity Window Platform я не могу получить URL-адрес из веб-браузера с помощью метода Application.OpenURL().
С помощью Unity, использующего Window Platform и Firebase, как я могу поддержать вход пользователя в социальную сеть Google?
Код: Выделить всё
private const string authorizationEndpoint_second = "https://accounts.google.com/o/oauth2/auth";
private const string new_redirectUri = "https://haxxxxn.xxxxxx.firebaseapp.com/__/auth/handler";
private const string clientId_second = "10497xxxxxx-hfxxxxxxxxxx8.apps.googleusercontent.com";
private const string scope_second = "email profile";
void Start()
{
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
{
if (task.Result == DependencyStatus.Available)
{
auth = FirebaseAuth.DefaultInstance;
}
else
{
Debug.LogError("Could not resolve Firebase dependencies: " + task.Exception);
return;
}
});
}
IEnumerator OpenOAuthURL()
{
auth = FirebaseAuth.DefaultInstance;
var credential = GoogleAuthProvider.GetCredential(clientId, clientSecret);
var authUrl_second = $"{authorizationEndpoint_second}?response_type=code&client_id={clientId_second}&redirect_uri={new_redirectUri}&scope={scope_second}";
Application.OpenURL(authUrl_second);
while (!Application.absoluteURL.StartsWith(new_redirectUri))
{
credential = GoogleAuthProvider.GetCredential(clientId, clientSecret);
yield return new WaitForSeconds(1);
}
//get authCode by parsing url now accessing
string authCode = GetAuthCodeFromUrl(Application.absoluteURL);
}
Использование веб-просмотра для получения URL-адреса. Но я не могу получить URL-адрес и установить URL-адрес аутентификации.
SDK для входа в Google бесполезен на платформе Window.
Подробнее здесь: https://stackoverflow.com/questions/782 ... w-platform
Мобильная версия