protected void RefreshAuthToken() { lock (AccessTokenLock) { if (AccessTokenExpires < DateTime.Now) { var req = HTTPHelper.CreateRequest(null, OAuthTokenRequestUri); var reqdata = new { refresh_token = RefreshToken, client_id = ClientId, client_secret = ClientSecret, grant_type = "refresh_token" }; var respdata = HTTPHelper.ToJson(HTTPHelper.SendUrlEncodedPostData(req, reqdata)); _AccessToken = respdata.access_token; _TokenType = respdata.token_type; AccessTokenExpires = DateTime.Now.Add(new TimeSpan((respdata.expires_in - 60) * 10000000)); } } }
public static dynamic PostCloudPrintUrlEncodedRequest(OAuthTicket ticket, string iface, dynamic postdata) { return(HTTPHelper.ToJson(HTTPHelper.SendUrlEncodedPostData(CreateCloudPrintRequest(ticket, iface), postdata))); }