【发布时间】:2014-09-22 10:22:08
【问题描述】:
Salesforce 会话会在 2 小时后自动超时,因此我们需要刷新令牌,任何人都可以建议用户必须每两小时通过 databasedotcom 重新授权应用程序。
【问题讨论】:
Salesforce 会话会在 2 小时后自动超时,因此我们需要刷新令牌,任何人都可以建议用户必须每两小时通过 databasedotcom 重新授权应用程序。
【问题讨论】:
这不是示例 Ruby 代码,而是描述了如何刷新令牌:
客户端应用程序通过向https://login.salesforce.com/services/oauth2/token POST 另一个请求 (4) 来获取新的访问令牌,这一次使用以下形式的有效负载:
grant_type = refresh_token&CLIENT_ID = 3MVG9lKcPoNINVBJGKrUKSXjJRTgKoeZx6OvJLXwLO8n80_OY.ydx0cQ24zGwBhRfa4YEWrFaNVVdI142EivZ&client_secret = 7868057769520845245&refresh_token = 5Aep861eWO5D.7wJBuW5aaARbbxQ8hssCnY1dw3qi59o1du7ob.lp23ba_3jMRnbFNT5R8X2GUKNA == P>
grant_type Set this to refresh_token.
client_id Your application's client identifier.
client_secret Your application's client secret (optional).
refresh_token The refresh token provided in the previous authorization.
在收到访问令牌后,客户端可以重复其请求 (5),向用户发送响应 (6),并继续服务请求 (7、8、9),直到新的访问令牌过期。
https://developer.salesforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com#Token_Refresh
【讨论】:
databasedomcom gem 如何像示例 ruby 代码一样重新授权
client.authenticate,它会获取新的令牌