【问题标题】:salesforce api error ReasonPhrase: 'Bad Request'salesforce api 错误 ReasonPhrase: 'Bad Request'
【发布时间】:2016-08-30 17:17:59
【问题描述】:

我访问这个https://test.salesforce.com/services/oauth2/authorizewerbservice 并在响应中获得一个代码。 现在使用此代码我想访问https://login.salesforce.com/services/oauth2/token

要访问这两种方法,我使用的是 c#.net。

当我尝试访问此https://login.salesforce.com/services/oauth2/token 时,我收到以下错误。

{
 StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content:  System.Net.Http.StreamContent, Headers:
{
  Strict-Transport-Security: max-age=10886400; includeSubDomains; preload
  Content-Security-Policy-Report-Only: default-src https:; script-src https: 'unsafe-inline' 'unsafe-eval'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:; report-uri /_/ContentDomainCSPNoAuth?type=login
  Pragma: no-cache
  Transfer-Encoding: chunked
  Cache-Control: no-store, no-cache
  Date: Tue, 30 Aug 2016 16:08:22 GMT
  Set-Cookie: BrowserId=pANkulkPTdesvcocxGm5Q;Path=/; Domain=.salesforce.com;Expires=Sat, 29-Oct-2016 16:08:22 GMT
  Content-Type: application/json; charset=UTF-8
  Expires: Thu, 01 Jan 1970 00:00:00 GMT
 }
}


 "{\"error\":\"invalid_grant\",\"error_description\":\"authentication failure\"}"

我尝试了一整天,但我无法解决问题。 下面是我的代码。你可以检查一下,请告诉我那里有什么问题。 我的代码在这里。

            HttpClient authClient = new HttpClient();

            string sfdcConsumerKey = "3MVG9e2mBbsdfsdfsdfZnmgdbcsdfM6nG7.s.sffsdfsfbgfbvdfgdfgyeinHsdfsf";
            string sfdcConsumerSecret = "54324324324324";
            string sfdcUserName = "harish@gmail.com";
            string sfdcPassword = "mypassword123456";
            string sfdcToken = "fsdcbvcvbfgerwcxvx";
            string loginPassword = sfdcPassword + sfdcToken;
            string code = Request.QueryString["code"];
            HttpContent content = new FormUrlEncodedContent(new Dictionary<string, string>
            {
                {"grant_type","authorization_code"},
                {"code",code},
                {"client_id",sfdcConsumerKey},
                {"client_secret",sfdcConsumerSecret},
                {"username",sfdcUserName},
                {"password",loginPassword},
                {"redirect_uri","http://localhost:1474/Default.aspx"}                  
            }
            );


            HttpResponseMessage message = await authClient.PostAsync("https://login.salesforce.com/services/oauth2/token", content);

            string responseString = await message.Content.ReadAsStringAsync();

【问题讨论】:

标签: c# asp.net salesforce


【解决方案1】:

【讨论】:

  • 您的第一个链接指向一个为俄罗斯新娘做广告的页面
猜你喜欢
  • 1970-01-01
  • 2015-03-08
  • 2021-12-20
  • 2013-09-26
  • 2012-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-28
相关资源
最近更新 更多