Documentation says that for OAuth2 token authorization URL like login.salesforce.com should be used

For authorization: https://login.salesforce.com/services/oauth2/authorize
For token requests: https://login.salesforce.com/services/oauth2/token
For revoking OAuth tokens: https://login.salesforce.com/services/oauth2/revoke

However, documentation doesn't tell anything about which other URL could be used for sandboxes and if lightning domain URL can be used for this?

For example, when I try to connect to https://domain--full.lightning.force.com/services/oauth2/token I receive unsupported_grant_type error response

  • 1
    "it is now clear"? That sounds like a typo. – sfdcfox Jun 27 '19 at 14:32
  • Updated to "However, documentation doesn't tell anything about which other URL could be used for sandboxes" – Patlatus Jun 27 '19 at 14:45

For sandboxes two URL types can be used:

  1. Generic URL like https://test.salesforce.com/services/oauth2/token
  2. Specific Classic Domain URL like https://domain--full.cs100.salesforce.com/services/oauth2/token

Lightning domain URL cannot be used.

Classic domain URL changes every refresh since Sandbox might migrate to another instance, so it is better to use always Generic URL

  • For MyDomain, I think it depends on the sequence of when mydomain was established; if you applied my domain to an existing sandbox, then the URL looks like https://domain--full.cs100.my.salesforce.com; if the sandbox came from PROD, then it would be https://domain--featureBox.my.salesforce.com (no ref to a pod) – cropredy Jun 28 '19 at 1:27
  • I have refreshed sandbox from production, and it has the instance name in the classic URL – Patlatus Jul 1 '19 at 8:18
  • What do you get if you create a new sandbox from Prod? – cropredy Jul 1 '19 at 13:39

https://test.salesforce.com/... is the right way to go for sandboxes.

From the doc

Instead of login.salesforce.com, customers can also use the My Domain, community, or test.salesforce.com (sandbox) domains in these endpoints.

(Admittedly, it's a very brief doc note)

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.