0

I use the databasedotcom gem, and at first everything works fine (I am able to list Salesforce resources and perform queries on them), but then at random it drops the connection and gives me

undefined method `[]' for nil:NilClass

for calls such as:

client.materialize("Account")
@accounts = Account.all

I am connecting to a dev account via OAuth with token & instance_url obtained by OmniAuth.

It's not hitting any API usage limits (35/5000) so I am wondering what's the problem?

Thank you!

0

The solution was quite simple - I wasn't requesting OAuth with refresh token. You can switch this setting to the Salesforce App (the option is called 'Perform requests on your behalf' in the OAuth scopes).

Then, when you log in via OAuth the hash it provides has additional item called 'refresh_token', you write this down and pass it to Databasedotcom::Client.new alongside client_id and secret every time you instantiate new client.

The docs were a bit scattered and it took me a while to understand the workflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.