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?


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

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.