简体   繁体   English

尝试通过Ruby on Rails和databasedotcom向OAuth2和Salesforce.com进行身份验证

[英]Trying to authenticate with OAuth2 and Salesforce.com with Ruby on Rails and databasedotcom

I am trying to use the databasedotcom gem to authenticate my application through Salesforce.com. 我正在尝试使用databasedotcom gem通过Salesforce.com对我的应用程序进行身份验证。 The documentation is weak and I am new at OAuth. 该文档薄弱,我是OAuth的新手。 I have configured my app in Salesforce.com and have my secret and key. 我已经在Salesforce.com中配置了我的应用程序,并拥有了我的秘密和密钥。 I am configuring from my environment: 我正在从我的环境中配置:

client = Databasedotcom::Client.new(:client_id => ENV['SALESFORCE_CONSUMER_KEY'], :client_secret => ENV['SALESFORCE_CONSUMER_SECRET'])

Now I am supposed to get a token and use it to authenticate. 现在,我应该获得一个令牌并将其用于身份验证。 How do I get a token? 我如何获得代币? There are options for an externally accessed token and one obtained with a username and password, but I am unsure of what to do next or how I was supposed to get the token. 有一个用于外部访问的令牌的选项,以及一个使用用户名和密码获得的令牌,但是我不确定下一步该怎么做或应该如何获取该令牌。 The documents continue as if I have it already and should know where it came from. 这些文件就像我已经有了一样继续,应该知道它来自哪里。

If all you need is to access the REST API of SFDC. 如果您需要的只是访问SFDC的REST API。

you can do this: 你可以这样做:

client.authenticate :username => 'user@example.com', :password => '123'

and then: 接着:

users = client.materialize('User').all

for example the above will return all the users in the user's Org. 例如,上面的代码将返回用户单位中的所有用户。

however...if you want follow the Oauth approach, and authenticate the databasedotcom gem using Oauth tokens, you can read more about oauth here: http://help.salesforce.com/help/doc/en/remoteaccess_oauth_web_server_flow.htm 但是...如果您想遵循Oauth方法,并使用Oauth令牌对databasedotcom gem进行身份验证,则可以在此处阅读有关oauth的更多信息: http : //help.salesforce.com/help/doc/zh-CN/remoteaccess_oauth_web_server_flow.htm

i crafted my own oauth access flow using the above link (i used Net::HTTP class) 我使用上面的链接制作了自己的oauth访问流(我使用了Net :: HTTP类)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM