[英]Ruby OAuth with Salesforce not getting refresh_token
I can't seem to get a refresh_token whenever I'm authorized, I've tried setting headers, kind of like how it would be done with google oauth, but not luck. 我似乎一经获得授权就无法获得refresh_token,我尝试设置标头,有点像用谷歌oauth来完成,但不走运。 Here's my process: 这是我的过程:
Using oauth2
gem 使用oauth2
gem
Instantiate client 实例化客户端
client = OAuth2::Client.new(
salesforce_app_key,
salesforce_secret_key,
site: 'https://login.salesforce.com/services/oauth2/',
authorize_url: 'https://login.salesforce.com/services/oauth2/authorize',
token_url: 'https://login.salesforce.com/services/oauth2/token',
raise_errors: false
)
Authorize connection 授权连接
auth = client.auth_code.authorize_url(
redirect_uri: 'https://my_app_callback.com/oauth/authorize'
)
Fetch token 获取令牌
token = client.auth_code.get_token(
code,
redirect_uri: 'https://my_app_callback.com/oauth/authorize'
)
From this point, I have the connection set, but when I do token.refresh_token
I get a nil value. 从这一点来说,我已经设置了连接,但是当我做token.refresh_token
我得到一个nil值。
By using: 通过使用:
access_token = OAuth2::AccessToken.new(oauth, token)
The session was reestablished successfully. 会话已成功重新建立。 It's in the docs, but not written in a way I could uderstand it's used to reauthenticate. 它在文档中,但没有以我能理解的方式编写,用于重新认证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.