Trying to debug the Salesforce invalid_grant ip restricted error? Here's how to fix it.
TABLE OF CONTENTS
What causes the Salesforce IP restricted error?
This Salesforce OAuth error can happen because of a trusted IP range policy that is in place for your Connected App.
Resolution for the IP restricted error
If you are getting this error, you can try two things.
1. First, you can try relaxing your Connected App’s IP policy. On your Salesforce account, go to Apps → Connected Apps → Manage Connected Apps → {{YOUR APP}} → Edit Policies and select Relax IP restrictions under the dropdown in IP Relaxation.
2. Alternatively (if you do not want to relax your app’s IP policy), you can define trusted IP ranges for your Connected App by going to your Connected App and clicking New in Trusted IP Range for OAuth Web Server Flow, and enter in your organization's trusted IP addresses.
For a more detailed guide on adding trusted IP ranges, check out Salesforce's docs on the topic.