Beispiel #1
0
        /// <summary>Gets the access token currently associated with the Unity activity.</summary>
        /// <returns>The OAuth 2.0 access token.</returns>
        public string GetAccessToken()
        {
            if (!this.IsAuthenticated())
            {
                Debug.Log("Cannot get API client - not authenticated");
                return(null);
            }

            if (!GameInfo.WebClientIdInitialized())
            {
                //don't spam the log, only do this every webclientWarningFreq times.
                if (noWebClientIdWarningCount++ % webclientWarningFreq == 0)
                {
                    Debug.LogError("Web client ID has not been set, cannot request access token.");
                    // avoid int overflow
                    noWebClientIdWarningCount = (noWebClientIdWarningCount / webclientWarningFreq) + 1;
                }
                return(null);
            }
            mTokenClient.SetRationale(rationale);
            return(mTokenClient.GetAccessToken());
        }