public AuthenticationProvider(string id, string secret) { client_id = id; client_secret = secret; request = string.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=http://api.microsofttranslator.com",HttpUtility.UrlEncode(client_id), HttpUtility.UrlEncode(client_secret)); token = HttpPost(); token_timestamp = DateTime.Now; }
public AccessToken GetAccessToken() { if (DateTime.Now > token_timestamp.AddMinutes(token_renewal_interval)) { token = HttpPost(); token_timestamp = DateTime.Now; } return token; }