I am trying to use OAuth authentication to get the Salesforce Authentication Token, so I referred wiki docs, but after getting authorization code, when I make a Post request
For OAuth 2 tokens if you login...
login.salesforce.com
use https://login.salesforce.com/services/oauth2/tokentest.salesforce.com
use https://test.salesforce.com/services/oauth2/tokenWhen I'd call curl https://login.salesforce.com/services/oauth2/token -d "...credentials..."
it still failed with:
{"error":"invalid_grant","error_description":"authentication failure"}
Realized there are different OAuth environments when reading Digging Deeper into OAuth 2.0 in Salesforce specifically (emphasis added):
OAuth 2.0 Authentication Endpoints
OAuth endpoints are the URLs that you use to make OAuth authentication requests to Salesforce. When your application makes an authentication request, make sure you’re using the correct Salesforce OAuth endpoint. The primary endpoints are:
- Authorization—https://login.salesforce.com/services/oauth2/authorize
- Token—https://login.salesforce.com/services/oauth2/token
- Revoke—https://login.salesforce.com/services/oauth2/revoke (see Revoke OAuth Tokens for details on revoking access)
Instead of login.salesforce.com, customers can also use the My Domain, community, or test.salesforce.com (sandbox) domains in these endpoints.
Because I logged into my environment via test.salesforce.com
switching to curl https://test.salesforce.com/services/oauth2/token -d "...credentials..."
resulted in a "Congrats! (>^_^)> Give OAuth token response"