When I try to login to my sandbox using SalesforceSharp, I'm getting the following error message:

InvalidGrant: Authentication Failure

Here's what I've done:

  • Pass in the username, password, clientId, and clientSecret (SalesforceSharp)
  • Append my security token to the end of my password (SalesforceSharp)
  • Set "Relax IP Restrictions" on the connected app that I created for API access (Salesforce UI)
  • Set "All users may self-authorize" (Salesforce UI)
  • Set authFlow.TokenRequestEndpointUrl = "https://test.salesforce.com/services/oauth2/token"; instead of the default login.salesforce.com... (after the default failed) (SalesforceSharp)

Any ideas?

  • Did you check the login history for the user to see what it reports the error as? One of the parameters you passed in is not correct or you are using credentials for sandbox and using login or vice versa – Eric Aug 17 '17 at 22:15
  • I haven't tried that particular library. Have you tried the Force.com Toolkit for .NET instead? – Daniel Ballinger Aug 17 '17 at 22:17
  • When I did OAuth against a sandbox I needed a ConsumerKey and ConsumerSecret from a connected app that was created in a Sandbox. Might also be worth a try. I don't believe this is an actual requirement, but for some reason it was the only way I could get it to work. – Daniel Ballinger Aug 17 '17 at 22:19

Your Answer

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

Browse other questions tagged or ask your own question.