【发布时间】:2020-11-26 15:10:22
【问题描述】:
我设置了一个 Connected App,这是一个 Python 应用程序,用于代表用户以编程方式访问 Salesforce 对象(离线访问)。
该应用程序有效,我可以生成一个access_token:
$ curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=MY_APP_CLIENT_ID" -d "client_secret=MY_APP_SECRET" -d "username=my@user.com" -d "password=my_password"
{"access_token":"00D09000000KDIX!AQoAQNi1234","instance_url":"https://my_instance.salesforce.com","id":"https://login.salesforce.com/id/12345/12345","token_type":"Bearer","issued_at":"1606401330889","signature":"abc/def"}
到目前为止一切顺利。
现在我想切换到使用刷新令牌的基于 Web 服务器的流程,但我被难住了。我在哪里可以得到最初的refresh_token 与grant_type=refresh_token 一起发送?文档似乎假设我已经有一个 refresh_token 并且只想基于此生成另一个 access_token,但事实并非如此。
端到端的实际步骤和必要的调用是什么?
我找到并阅读的文档列表,但让我没有更聪明:
- https://help.salesforce.com/articleView?id=remoteaccess_oauth_tokens_scopes.htm&type=5
- https://help.salesforce.com/articleView?id=remoteaccess_oauth_refresh_token_flow.htm&type=5
- https://developer.salesforce.com/forums/?id=906F0000000AgInIAK
- https://help.salesforce.com/articleView?id=connected_app_create_api_integration.htm&type=5
【问题讨论】:
-
您要实施哪个 OAuth 流程?听起来您可能需要 Web Server 或 User Agent 流,但如果您正在构建无头离线应用程序,则可能需要 JWT。
-
@DavidReed JWT,最终。但现在:
Now I wanted to switch to a web-server-based flow that uses refresh tokens.
标签: salesforce salesforce-lightning