Salesforce OAuth - 错误响应错误

时间:2016-08-10 02:42:43

标签: c# salesforce

我下载了Salesforce .Net sample以进行OAuth功能测试。

我的开发者帐户配置是,

enter image description here

我的Webconfig, enter image description here

我在没有问题的情况下获得了Auth令牌,并且它击中了Callback控制器。

但是当它执行时,

await auth.WebServerAsync(_consumerKey, _consumerSecret, _callbackUrl, code, _tokenRequestEndpointUrl);

获取Accesstoken的代码我收到错误,(这是因为它无法解析非常奇怪的响应。)

  <Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
</ExceptionMessage>
<ExceptionType>Salesforce.Common.ForceAuthException</ExceptionType>
<StackTrace>
at Salesforce.Common.AuthenticationClient.<WebServerAsync>d__28.MoveNext() in C:\Users\DhanukaS.INFRONT\Desktop\SFNew\SFNew\src\CommonLibrariesForNET\AuthenticationClient.cs:line 139 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at WebServerOAuthFlow.Web.Controllers.CallbackController.<Get>d__4.MoveNext() in C:\Users\DhanukaS.INFRONT\Desktop\SFNew\SFNew\samples\WebServerOAuthFlow\WebServerOAuthFlow.Web\Controllers\CallbackController.cs:line 23 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
</Error>

然后我调试了#34; WebServerAsync&#34;代码,发现我收到400 Bad Request。

我发布的是

grant_type=authorization_code&client_id=3MVG9ZL0ppGP5UrCKIMxh0dN7HmIE24cMYzog1sD.wPQIOTmpDkaoh5SYOcvKQ7ckwl7pw9H3KWQHHhHwR.gv&client_secret=xxxxxxxxxxx79169&redirect_uri=http%3A%2F%2Flocalhost%3A6054%2Fapi%2Fcallback&code=aPrxqJ8A8kLOza.c1DZ2Ye1YZ09ybmbRd8xxxxxxxxxxxx9qmE.LGHsyUJA2OKC25.qD.g%3D%3D

在回复中说,

    <!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Stronger security is required</title>
<style>
@font-face{
    font-family:'SalesforceSansLight';src:url('https://www.salesforce.com/system/shared/common/assets/fonts/SalesforceSans/SalesforceSans-Light.eot');
    src:url(..........'

我尝试了与另一个应用程序类似的事情,结果相同。我是否必须从Salesforce帐户进行任何配置。惊讶为什么这个基本情景不起作用?

参考this,即使对于localhost也强制使用HTTPS吗?

0 个答案:

没有答案