我正在使用Force.com Toolkit for .NET并尝试连接到Salesforce。请参阅下面的代码。
<script>
执行此操作时,我收到以下错误(如果指出):
var instance = "test101";
var testMode = !instance.ToUpper().Equals("LIVE");
using (var auth = new AuthenticationClient())
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
auth.UsernamePasswordAsync(_consumerKey,
_consumerSecret,
_salesforceUser + (testMode ? "." + instance : ""),
_salesforcePass,
$"http://{(testMode ? "test" : "login")}.salesforce.com/services/oauth2/token"
).GetAwaiter().GetResult(); // error here
_client = new ForceClient(auth.InstanceUrl, auth.AccessToken, "v30.0");
}
有很多链接表明内容类型Salesforce.Common.ForceAuthException: 'grant type not supported'
会解决此问题,但无法使用此方法指定此内容。
我已查看此链接Error with SalesForce authentication from C# Client(s),但根据文档(https://github.com/developerforce/Force.com-Toolkit-for-NET),它使用的是HttpClient而不是身份验证客户端。
有人有这个工作吗?