private void SuccessHandler(string tokenInfo) { Debug.Log("IosSocialAuth.SuccessHandler: Token info received"); var response = ParseUtils.FromJson <LoginOAuthJsonResponse>(tokenInfo); PlayerPrefs.SetString(Constants.LAST_SUCCESS_AUTH_TOKEN, response.access_token); PlayerPrefs.SetString(Constants.LAST_SUCCESS_OAUTH_REFRESH_TOKEN, response.refresh_token); //Set expiration time for expiration check on next application start var expirationTime = DateTime.Now.AddSeconds(response.expires_in); PlayerPrefs.SetString(Constants.OAUTH_REFRESH_TOKEN_EXPIRATION_TIME, expirationTime.ToString()); Token.Instance = Token.Create(response.access_token); base.OnSuccess?.Invoke(response.access_token); }
private void UploadPicture(Sprite sprite) { bool?isImageUploaded = null; ShowWaiting(() => isImageUploaded == null); byte[] data = ConvertToData(sprite, out string boundary); var token = Token.Instance; SdkLoginLogic.Instance.UploadUserPicture(token, data, boundary, onSuccess: imageInfo => { var packedInfo = ParseUtils.FromJson <UserImageUpload>(imageInfo); if (packedInfo != null) { var pictureUrl = packedInfo.picture; SetPictureUrlToInfo(pictureUrl, onSuccess: () => { ImageLoader.Instance.AddImage(pictureUrl, sprite); RefreshImageLoaders(); isImageUploaded = true; }, onError: () => isImageUploaded = false); } else { Debug.LogError($"Could not parse server response: {imageInfo}"); } }, onError: error => { isImageUploaded = false; StoreDemoPopup.ShowError(error); }); }