public void tokenProviderTokenExpired(object s, TokenExpiredEventArgs e) { var dic = new Dictionary <string, string>(); dic.Add("client_id", ClientId); dic.Add("client_secret", ClientSecret); dic.Add("refresh_token", e.RefreshToken); dic.Add("scope", "cdr"); dic.Add("grant_type", "refresh_token"); string postData = ""; string postDataSperator = ""; foreach (var i in dic) { postData += string.Format("{0}{1}={2}", postDataSperator, HttpUtility.UrlEncode(i.Key), HttpUtility.UrlEncode(i.Value)); postDataSperator = "&"; } using (WebClient client = new WebClient()) { string str = client.UploadString(Endpoints.Token, postData); if (string.IsNullOrEmpty(str)) { return; } JObject jsonResult = JObject.Parse(str); ((Token)s).SetAccessToken(jsonResult.GetValue("access_token").ToString()); ((Token)s).SetRefreshToken(jsonResult.GetValue("refresh_token").ToString()); } }
public void tokenProviderTokenExpired(object s, TokenExpiredEventArgs e) { var dic = new Dictionary<string, string>(); dic.Add("client_id", ClientId); dic.Add("client_secret", ClientSecret); dic.Add("refresh_token", e.RefreshToken); dic.Add("scope", "cdr"); dic.Add("grant_type", "refresh_token"); string postData = ""; string postDataSperator = ""; foreach(var i in dic) { postData += string.Format("{0}{1}={2}", postDataSperator, HttpUtility.UrlEncode(i.Key), HttpUtility.UrlEncode(i.Value)); postDataSperator = "&"; } using (WebClient client = new WebClient()) { string str = client.UploadString(Endpoints.Token, postData); if (string.IsNullOrEmpty(str)) { return; } JObject jsonResult = JObject.Parse(str); ((Token)s).SetAccessToken(jsonResult.GetValue("access_token").ToString()); ((Token)s).SetRefreshToken(jsonResult.GetValue("refresh_token").ToString()); } }