gpt4 book ai didi

ruby-on-rails - 将 Restforce gem 与 SalesForce API 和 Oauth 2.0 结合使用

转载 作者:行者123 更新时间:2023-12-04 14:45:05 26 4
gpt4 key购买 nike

我正在尝试使用 Restforce ( https://github.com/ejholmes/restforce ) 使用 Oauth 2.0 将我的 Rails 应用程序集成到 SalesForce 的 API。

Restforce 对初始化过程的描述如下:

Initialization

Which authentication method you use really depends on your use case. If you're building an application where many users from different orgs are authenticated through oauth and you need to interact with data in their org on their behalf, you should use the OAuth token authentication method.

If you're using the gem to interact with a single org (maybe you're building some salesforce integration internally?) then you should use the username/password authentication method.

OAuth token authentication

client = Restforce.new :oauth_token => 'oauth token',
:instance_url => 'instance url'

Although the above will work, you'll probably want to take advantage of the (re)authentication middleware by specifying a refresh token, client id and client secret:

client = Restforce.new :oauth_token => 'oauth token',
:refresh_token => 'refresh token',
:instance_url => 'instance url',
:client_id => 'client_id',
:client_secret => 'client_secret'


我有我的 client_idclient_secret来自在SF中创建的应用程序,但不知道我需要将哪些其他信息放入restforce。

有没有人对这个 gem 有任何经验?如何使用它向SF发出原始请求 token 请求?

最佳答案

您需要先使用 Oauth 2.0 登录,然后将 token 提供给 gem。
我是用 Omniauth-Salesforce 做到的并在传递 token 后,我恢复了restforce。

omn​​iauth 中的例子使用的是sinatra,请查看this repo for an implementation using rails .

我已经 blogged about this as well .

关于ruby-on-rails - 将 Restforce gem 与 SalesForce API 和 Oauth 2.0 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22899617/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com