I'm getting the following error authenticating with the UN/PW oauth2 flow (I redacted the actual domain name):

Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://CUSTOM_DOMAIN.cs32.my.salesforce.com/services/oauth2/token

I have added a remote site setting for this domain but the error is persisting. Has anyone else experienced this doing oauth2 callouts to orgs with custom login domains?

NOTE: this org does have this checkbox enabled Prevent login from https://test.salesforce.com.


    if (customer.thisOrg.domain_override__c!=null) {
    else {
        //check to see if type is sandbox or production/developer
        if(customer.thisOrg.type__c == 'Sandbox'){
        '&client_id='+' CLIENT_ID'+

    httpResponse res = new httpResponse();

    try {
        // send request     
        Http http = new Http();
        // capture response
        res = http.send(req);
        system.debug('authentication response: '+ res.getBody());
    catch (exception e) {
        system.debug('error authenticating with customer: '+ e.getMessage());
        customer.log += '\n\n error authenticating: ' + e.getMessage(); 
          return null;
  • have you added https://CUSTOM_DOMAIN.cs32.my.salesforce.com/ in remote site.. If yes also try to add https://test.salesforce.com
    – Ratan Paul
    Feb 17, 2016 at 17:02
  • yep, I did. I included that in my question. I'm able to authenticate fine with other orgs both sandboxes and production. EDIT: yes test.salesforce.com is in there as well.
    – Phil B
    Feb 17, 2016 at 17:03
  • Are you using SOAP API callout?
    – Ratan Paul
    Feb 17, 2016 at 17:07
  • @Ratan no I'm not
    – Phil B
    Feb 17, 2016 at 17:08
  • Phil what is your endpoint you are using?
    – Ratan Paul
    Feb 17, 2016 at 17:12

1 Answer 1


It appears that the Remote Site is case sensitive (not sure why) so if you encounter this error please verify the casing.

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.