C# 获取access_token异常
黑面小男生 发布于2018-04 浏览:2712 回复:3
0
收藏

在使用获取 access_token方法的时候报这个异常: An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll,
怎么解?请求大神帮吗解决

我用的是 c# 的调用,以下是 C# 的 API 文档中的调用代码,测试的时候会在红色字体的地方报这个异常

String authHost = "https://aip.baidubce.com/oauth/2.0/token";
HttpClient client = new HttpClient();
List> paraList = new List>();
paraList.Add(new KeyValuePair("grant_type", "client_credentials"));
paraList.Add(new KeyValuePair("client_id", clientId));
paraList.Add(new KeyValuePair("client_secret", clientSecret));

HttpResponseMessage response = client.PostAsync(authHost, new FormUrlEncodedContent(paraList)).Result;
result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
return result;

收藏
点赞
0
个赞
共3条回复 最后由用户已被禁言回复于2022-04
#4lichao_86回复于2018-10

mscorlib.dll版本不对?

0
#3追星逐月的家回复于2018-07

c#不是有现成代码么

0
#2goJhou回复于2018-04

参照一下我框架中的获取AccessToken代码

0
TOP
切换版块