谷歌玩游戏认证与firebase无法在Unity上运行

时间:2019-12-08 22:23:19

标签: firebase unity3d authentication firebase-authentication google-play-games

我已经按照{{3}}的官方说明在Unity上使用Firebase配置Google Play游戏身份验证,但是很遗憾,它无法正常工作。我认为当尝试从玩游戏中请求身份验证ID时,身份验证过程将失败。 这里是logcat的日志:

using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using Firebase.Auth;

public class GPGClient : MonoBehaviour
{
    private string authCode;
    private FirebaseAuth auth;
    public Text UserID;

    private void Start()
    {
        Debug.Log("start");
        UserID.text = "user";
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
            .RequestServerAuthCode(false /* Don't force refresh */)
            // requests an ID token be generated.  This OAuth token can be used to
            //  identify the player to other services such as Firebase.
            .RequestIdToken()
            .Build();

        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();

    }

    public void SignIn()
    {
        authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
        Debug.Log("authcode  " + authCode);
        Debug.Log("punt
    {
        authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
        Debug.Log("authcode  " + authCode);
        Debug.Log("punto0");
        // Google Play Games authentication.
        Social.localUser.Authenticate((success, message) =>
        {
            Debug.Log("authentication message " + message);
            if (success) 
            {
                //authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
                Debug.Log("autenticated");
                GoOnSignIn();
            }
            else
                Debug.Log("not yet autenticated");


        });



        Debug.Log("punto1");



    }

    private void GoOnSignIn() 
    {
        Debug.Log("punto1.1");
        // Firebase authentication.
        auth = FirebaseAuth.DefaultInstance;

        Credential credential =
            PlayGamesAuthProvider.GetCredential(authCode);
        Debug.Log("punto1.2");
        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            Debug.Log("punto2");
            if (task.IsCanceled)
            {
                Debug.Log("punto2cancel");
                UserID.text = "SignInWithCredentialAsync was canceled.";
                return;
            }
            if (task.IsFaulted)
            {
                Debug.Log("punto2fault");
                UserID.text = "SignInWithCredentialAsync encountered an error: " + task.Exception;
                return;
            }
            Debug.Log("punto3");
            FirebaseUser newUser = task.Result;
            UserID.text = "User signed in successfully: {0} ({1})" +
                newUser.DisplayName + newUser.UserId;
        });

        CreateUser();
    }

这里是代码:

def find_largest_clique(graph):
    def clique_size(graph, k):
        all_nodes = graph.nodes[:]
        '''TO CHECK IF CURRENT NUMBER OF NODES IS LESS THAN K, RETURN FALSE'''
        if len(all_nodes) < k:
                return False
        current_nodes = all_nodes[:]
        for nodes in current_nodes:
            adj_nodes = graph.adjacent_nodes(nodes)
            if len(adj_nodes) < k - 1:
                all_nodes.remove(nodes)
                graph.remove_node(nodes)

        if len(all_nodes) < k:
            return False
        return True


    clique = []

    all_nodes = graph.nodes[:]

    print(all_nodes)
    if len(all_nodes) < 2:
        return None

    '''FIND LARGEST CLIQUE SIZE'''
    k = 2
    while clique_size(graph, k):
        k += 1
    k -= 1
    print(k)
    if graph is None:
        return None
    '''FIND CLIQUE'''
    remaining_nodes = graph.nodes[:]

    for nodes in remaining_nodes:
        if graph.adjacent_nodes(nodes) == []:
            graph.remove_node(nodes)

    if graph.nodes == []:
        return None

    clique = graph.nodes[:]
    print(clique)
    return clique    

希望有人可以帮助我!谢谢!

0 个答案:

没有答案