public void RefreshAccessToken(IRefreshedTokenRequester requester) { List <IMultipartFormSection> parameters = new List <IMultipartFormSection>(); parameters.Add(new MultipartFormDataSection("client_secret", credentials.client_secret)); parameters.Add(new MultipartFormDataSection("grant_type", "refresh_token")); parameters.Add(new MultipartFormDataSection("refresh_token", authentificator.gat.refresh_token)); parameters.Add(new MultipartFormDataSection("client_id", credentials.client_id)); parameters.Add(new MultipartFormDataSection("t", getUTCTime())); Utility.Instance.StartCoroutine(authentificator.GetNewAccessToken(UnityWebRequest.Post(credentials.token_uri, parameters), requester)); }
public IEnumerator GetNewAccessToken(UnityWebRequest getAccessTokenHTTPRequest, IRefreshedTokenRequester requester) { UnityWebRequest NewAccessTokenRequest = getAccessTokenHTTPRequest; NewAccessTokenRequest.chunkedTransfer = false; NewAccessTokenRequest.timeout = 100000; yield return(NewAccessTokenRequest.SendWebRequest()); if (NewAccessTokenRequest.isNetworkError || NewAccessTokenRequest.isHttpError) { Debug.Log(NewAccessTokenRequest.downloadHandler.text); } else { string refresh_token = gat.refresh_token; gat = JsonUtility.FromJson <GoogleAccessToken>(NewAccessTokenRequest.downloadHandler.text); gat.refresh_token = refresh_token; requester.AfterRefreshedToken(); } }