Getting invalid_grant: authentication failure

1.2k Views Asked by At

I try to connect to salesforce via restforce gem. I use next:

client = Restforce.new(username: '[email protected]',
                           password: 'my_password',
                           client_id: 'Consumer_Key',
                           client_secret: 'Consumer_Secret',
                           security_token: 'security_token',
                           api_version: '38.0',
                           grant_type: 'password',
                           ssl: {version: 'TLSv1'})
contacts = client.query("select ID__c from Contacts where Name = 'Lorem Ipsum'")
puts contacts.first

When I try to execute it I'm getting next error: 'authenticate!': invalid_grant: authentication failure (Restforce::AuthenticationError)

In salesforce app I set:

  • Permitted Users: All users may self-authorize.
  • IP Relaxation: Relax IP restrictions.

Checked with enabled and disabled OAuth.

Also I've tried with simple configuration:

client = Restforce.new(username: '[email protected]',
                       password: 'my_password',
                       client_id: 'Consumer_Key',
                       client_secret: 'Consumer_Secret',
                       api_version: '38.0',)

But got the same error

Valid credentials for salesforce were specified.

What I did wrong?

0

There are 0 best solutions below