【发布时间】:2020-01-08 18:19:05
【问题描述】:
我正在使用带有以下代码的 azure 函数 - 当我在本地运行 azure fucntion 时一切正常,但部署后我遇到错误
{"error":"invalid_grant","error_description":"身份验证失败"}
功能代码-
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "tokenURL");
var keyValues = new List<KeyValuePair<string, string>>();
keyValues.Add(new KeyValuePair<string, string>("grant_type", "password"));
keyValues.Add(new KeyValuePair<string, string>("client_id", "clientID"));
keyValues.Add(new KeyValuePair<string, string>("client_secret", "clientSecret"));
keyValues.Add(new KeyValuePair<string, string>("username", "userName"));
keyValues.Add(new KeyValuePair<string, string>("password", "password"));
request.Content = new FormUrlEncodedContent(keyValues);
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
HttpResponseMessage response = await httpClient.SendAsync(request);
string respContent = await response.Content.ReadAsStringAsync();
var oauthResponse = JsonConvert.DeserializeObject<Dictionary<string, string>>(respContent);
string token = oauthResponse["access_token"];
salesforce 是否需要任何其他设置?
修改连接的应用程序:(编辑策略)放宽 IP 限制
Permitted Usersto“所有用户都可以自行授权”
【问题讨论】:
标签: c# azure salesforce azure-functions