与Salesforce的Ruby OAuth没有得到refresh_token
问题描述:
我似乎无法得到一个refresh_token每当我被授权,我试着设置标题,有点像谷歌oauth将如何做,但不是运气。这里是我的过程:与Salesforce的Ruby OAuth没有得到refresh_token
使用oauth2
宝石
实例化客户端
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
)
授权连接
auth = client.auth_code.authorize_url(
redirect_uri: 'https://my_app_callback.com/oauth/authorize'
)
取令牌
token = client.auth_code.get_token(
code,
redirect_uri: 'https://my_app_callback.com/oauth/authorize'
)
从这一点,我有连接设置,但是当我做token.refresh_token
我得到一个零值。
答
使用:
access_token = OAuth2::AccessToken.new(oauth, token)
本届会议的成功重建。它在文档中,但不是以我可以理解的方式编写的,用于重新进行验证。