I'm trying to get an OAuth2 token in a scratch org, I set up a connected app and tried just about every way that I could think of. I attempted to use my scratch org url and test, this is what my constructed request looks like.. And Ideas?

https://test.salesforce.com/services/oauth2/token?client_id=3MVG9eQyYZ1h89Hfv65svH6r.cVHnDV_W3sRTxUpxQK3HJce_hZQdBUcqSL4AzPFWq0ieiDs5XY4ThQiWa1lv&client_secret=66E3451CD2458CBDEE0AD3BAE9FC85DCB021492E1EC7E23D1298FEB628C6B0B3&password=mypasswordhasa&init&[email protected]&grant_type=password

I've also appended my security token to the end of my password with no success, is it possible to hit /services/oauth2/token in a scratch org?

  • 2
    Be sure to change your password as soon as you see this comment.
    – sfdcfox
    Mar 6, 2020 at 17:08

1 Answer 1


Special characters in the username or password need to be URL encoded. While I ordinarily don't approve of posting access credentials in a forum, especially here, it's apparent that the & in your password is causing the problem. The & should be encoded as %26. And yes, you should be using your scratch org's host name to get the token; Scratch Orgs do not participate in the test.salesforce.com login domain. Also, the username should be encoded as test-zg06ribwccg2%40example.com (the @ symbol should be %40).

  • Are the - okay?
    – EricSSH
    Mar 6, 2020 at 17:11
  • @EricSSH Yes, that's fine. See Percent Encoding for characters you must encode, plus their %-encoded values.
    – sfdcfox
    Mar 6, 2020 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .