You need to sign in to do that
Don't have an account?
betterbhushan
Connect Ruby to Salesforce via OAuth
Has anybody connected to Salesforce through Rails 3 App via oauth? Could you please post code for doing same. I am trying to same but I get some error below is my code.
def oauth_client consumer_key = '....' consumer_secret = '....' 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', } OAuth::Consumer.new consumer_key, consumer_secret, oauth_options end def oauth_redirect_uri uri = URI.parse(request.url) uri.path = '/sfdc/oauth_callback' uri.query = nil # uri = "http://localhost:3000/sfdc/oauth_callback" uri.to_s end def oauth_connect consumer_key = '...' # from SalesForce consumer = oauth_client request = consumer.get_request_token redirect_to request.authorize_url( :redirect_uri => oauth_redirect_uri, :oauth_consumer_key => consumer_key ) end def oauth_callback access = request.get_access_token :oauth_verifier => params[:oauth_verifier] p access render :text => access.token end
Error undefined method get_access_token for #<ActionDispatch::Request:0x12b79f370>. the request variable is nil here. How do I get it back?
It's difficult to reply with that chunk of code. At least give us the entire Class. It looks like a controller but I am not sure what are you working with (which gem for ex).
When calling a controller method, request object instance definition is as follow http://api.rubyonrails.org/classes/ActionDispatch/Request.html
To get more info about your request at that time, just add a trace like:
you should see your callback return and find where in the hash stand your token.
enjoy
----Vzmind