public static SendUrlEncodedPostData ( |
||
request | ||
postdata | dynamic | |
Résultat | byte[] |
public static OAuthTicket FromAuthCode(string authcode, string clientid, string clientsecret, string redirecturi) { var req = HTTPHelper.CreateRequest(null, OAuthTokenRequestUri); var reqdata = new { code = authcode, client_id = clientid, client_secret = clientsecret, redirect_uri = redirecturi, grant_type = "authorization_code" }; var respdata = HTTPHelper.ToJson(HTTPHelper.SendUrlEncodedPostData(req, reqdata)); return(new OAuthTicket { ClientId = clientid, ClientSecret = clientsecret, RedirectUri = redirecturi, _RefreshToken = respdata.refresh_token, _AccessToken = respdata.access_token, _TokenType = respdata.token_type, AccessTokenExpires = DateTime.Now.Add(new TimeSpan((respdata.expires_in - 60) * 10000000)) }); }
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))); }