我正在使用salesforce rest api从我的rails应用程序访问salesforce帐户。我创建了一个远程访问应用程序,并获得了密钥N the id。我能够对用户进行身份验证,并获得auth_token、实例url等所有信息。但是,当我在"instance_url/services/data/v20.0“和访问令牌一起发送请求时,我得到了这个错误:
[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]我有一个开发者salesforce帐户,并为每个配置文件启用API,除了“认证网站”配置文件(这是不可访问的)。
有谁能帮我一下吗?
我正在使用以下请求验证用户
HTTParty.post "login.salesforce.com/services/oauth2/token";, :body=>{"grant_type"=>"authorization_code","code"=>"abc}","client_secret"=>"abc", "client_id"=>"abc","format"=>"json","redirect_uri"=>"localhost:3000/salesforce/callback";}返回签名、id、instance_url、issued_at、access_token和refresh_token
HTTParty.get "ap1.salesforce.com/services/data/v20.0";, :headers=>{"Authentication"=>"OAuth access_token", "Content-Type"=>"application/json"}它的响应是
[{"errorCode"=>"INVALID_SESSION_ID", "message"=>"Session expired or invalid"}]发布于 2011-05-23 23:39:51
您如何将数据传递给/ sessionId /data/v20.0请求?如果您的access_token是abc123,那么在请求中需要一个Authorization: OAuth abc123的http头。
发布于 2011-05-24 03:45:52
无论是否有活动,salesforce中的API会话都会过期。要设置每个会话的持续时间,请转到Setup > Administration Setup > Security Controls > Session Settings>
最大值为8小时。
干杯!
发布于 2011-05-24 11:56:36
如果您使用的是Oauth,则需要在出现此错误时使用刷新令牌流来获取新的续订令牌。以下是更多详细信息:http://wiki.developerforce.com/index.php/Digging_Deeper_into_OAuth_2.0_on_Force.com
请在上面的WIKI页面链接中搜索“刷新令牌”。
https://stackoverflow.com/questions/6095352
复制相似问题