2

持っclient_idclient_secretいますが、認証するには が必要oauth_tokenです。Ruby on Rails を使用してこのトークンを取得するにはどうすればよいですか? いくつかのオプションで試しましたが、うまくいきませんでした。

使用された宝石: databasedotcom

以下のオプションを試しましたが、応答しません https://gist.github.com/undees/300175

require 'oauth'

consumer_key    = '...' # from SalesForce
consumer_secret = '...' # from SalesForce

oauth_options = {
:site               => 'https://login.salesforce.com',
:scheme             => :body,
:request_token_path => '/_nc_external/system/security/oauth/RequestTokenHandler',
:authorize_path     => '/setup/secur/RemoteAccessAuthorizationPage.apexp',
:access_token_path  => '/_nc_external/system/security/oauth/AccessTokenHandler',
}
consumer = OAuth::Consumer.new consumer_key, consumer_secret, oauth_options
# consumer.http.set_debug_output STDERR # if you're curious 
request       = consumer.get_request_token
authorize_url = request.authorize_url :oauth_consumer_key => consumer_key 
puts "Go to #{authorize_url} in your browser, then enter the verification code:"
verification_code = gets.strip 
access = request.get_access_token :oauth_verifier => verification_code

puts "Access Token:  " + access.token
puts "Access Secret: " + access.secret
4

1 に答える 1

0

解決策:databasedotcom-oAuth2 gemがうまくいきました。クライアントキーとシークレットを取得し、セールスフォースとやり取りします。詳細はこちらに記載されています。ここをクリックhttp://wiki.developerforce.com/page/Introduction_to_the_databasedotcom-oauth2_Gem

于 2013-05-02T06:46:49.503 に答える