Пример #1
0
    IEnumerator GetRefreshToken()
    {
        UnityWebRequest webRequest = UnityWebRequest.Get($"http://teal-fire.com/MapMoves/refresh.php?refresh={currentResponse.refresh_token}");

        yield return(webRequest.SendWebRequest());

        if (webRequest.isNetworkError || webRequest.isHttpError)
        {
            Debug.Log("<b>GOOGLE PHOTOS</b> - Could not refresh access token");
        }
        else
        {
            Debug.Log("<b>GOOGLE PHOTOS</b> - Access token refreshed");
            GoogleOauthResponse response = JsonConvert.DeserializeObject <GoogleOauthResponse>(webRequest.downloadHandler.text);
            response.SetEndTime();
            PlayerPrefs.SetString("GoogleOauthResponse", EncryptString(JsonConvert.SerializeObject(response), key, iv));
            currentResponse = response;
            SendRequest();
        }
    }
Пример #2
0
    void TryGetTokenJson()
    {
        string tempString = GUIUtility.systemCopyBuffer;

        try {
            string decrypted = this.DecryptString(tempString, key, iv);
            Debug.Log(decrypted);
            GoogleOauthResponse response = JsonConvert.DeserializeObject <GoogleOauthResponse>(decrypted);
            response.SetEndTime();
            PlayerPrefs.SetString("GoogleOauthResponse", EncryptString(JsonConvert.SerializeObject(response), key, iv));
            Debug.Log("<b>GOOGLE PHOTOS</b> - Recieved api keys");
            currentResponse = response;
            waitingForToken = false;
            animator.SetTrigger("Close");
            couldNotRecognise.SetActive(false);
            loggedIn.SetActive(true);
            OnLogin();
            SendRequest();
        } catch (Exception ex) {
            Debug.Log("Invalid JSON!");
            couldNotRecognise.SetActive(true);
        }
    }