Sign In Register

How can we help you today?

Start a new topic

Google Play Authentication Unity - How do I Reference My Access Code?

I'm trying to add Google Play user authentication for my Android mobile game made with Unity. The problem is on line 31, where I said "PlayGamesPlatform.Instance.GetAccesToken()". I then get the following error in Unity's console: "Type `GooglePlayGames.PlayGamesPlatform' does not contain a definition for `GetAccessToken' and no extension method `GetAccessToken' of type `GooglePlayGames.PlayGamesPlatform' could be found. Are you missing an assembly reference?"


  

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using GameSparks.Api.Requests;
using GooglePlayGames;

public class Authenticate : MonoBehaviour {

    public Text log;

    public GameObject playButton;

    void Start()
    {
        PlayGamesPlatform.Activate();
    }

    public void GooglePlayStart()
    {
        Social.localUser.Authenticate((bool success) =>
        {
            playButton.SetActive(true);
            log.text = "Success";
        });
    }

    public void GooglePlayAuthenticate(int scene)
    {
        new GooglePlusConnectRequest().SetAccessToken(PlayGamesPlatform.Instance.GetAccessToken()).Send((response) =>
        {
            if (!response.HasErrors)
            {
                Debug.Log(response.DisplayName + " has logged in!");
                log.text = response.DisplayName + " has logged in!";
                SceneManager.LoadScene(scene);
            }
            else
            {
                Debug.Log("Not Logged In!");
                log.text = response.JSONString;
            }
        });
    }
} 

  

1 Comment

I was following this tutorial on the GameSparks website:

https://support.gamesparks.net/support/discussions/topics/1000063337

Login to post a comment