Salesforce返回“unsupported_grant_type”

我们使用Web服务器身份验证流程实现了OAuth 2.0.它在10月/ 11月工作正常,但突然间它已经停止工作了.每当我们尝试授权另一个客户端时,服务器返回(400)与主体的错误请求

{"error":"unsupported_grant_type","error_description":"grant type not supported"}

grant_type设置为authorization_code,绝对有效.

OAuth突然停止工作有什么理由吗?

这就是我们实施OAuth的方式:

第一个用户被引导至:https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=blah.id&redirect_uri=https://domain.com/Web/Salesforce/Callback.aspx&scope=api%20refresh_token

Salesforce会提示用户登录其帐户.

一旦用户通过身份验证,Salesforce就会调用Callback.aspx,Callback.aspx代表客户端请求刷新令牌,方法是通过发送POST请求:https://login.salesforce.com/services/oauth2/token和有效负载:

grant_type = authorization_code&安培;代码= blah.code&安培; CLIENT_ID = blah.Id&安培; client_secret = 11111111&安培; REDIRECT_URI = HTTPS://domain.com/Web/Salesforce/Callback.aspx

内容类型绝对是:application / x-www-form-urlencoded

最佳答案 经过fiddler的大量摆弄后发现在HTTP POST有效负载中的grant_type = authorization_code之前有一个空格导致了这个问题.

有趣的是,自7月以来,代码库中存在空间,并且该问题于1月14日首次被注意到.在grant_type = authorization_code之前,Salesforce可能修复了错误或进行了内部更改以拒绝空间.

点赞