function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ryan Avent 14Ryan Avent 14 

LOGIN_ERROR_RESTR_DOMAIN (Web Server Flow)

I have a LWC that allows users to setup our integration from within salesforce, for one of our customers this is no longer working and we are seeing the below error being passed to our redirect url as paramaters

'LOGIN_ERROR_RESTR_DOMAIN' 

authorization page must be loaded from initial domain

Log from our endpoint

Request(GET //{our redirectURL}?error=LOGIN_ERROR_RESTR_DOMAIN&error_description=authorization+page+must+be+loaded+from+initial+domainstate={{removed for security}})

LWC code to Open login 

if (this.consumerKey && this.consumerSecret && this.codeURL) {
    //opens salesforce window that will send the authorization code to the endpoint declared as 'redirect_uri'
    window.open('https://login.salesforce.com/services/oauth2/authorize?'
        + 'response_type=' + 'code' + '&'
        + 'client_id=' + this.consumerKey + '&' 
        + 'redirect_uri=' + this.codeURL + '&'
        + 'state={\"client_secret\":\"' + this.consumerSecret
        +       '\",\"client_id\":\"' + this.consumerKey
        +       '\",\"instance_url\":\"' + response.substring(14, response.length - 1)
        +       '\",\"redirect_uri\":\"' + this.codeURL + '\"}'
        , '_blank'
    );

    //enabling "Continue" button
    this.disableCont = false;
}

We retrieve the customers URL via the below apex which we use to set the state paramater (seen below) the other vairables are enterd by the user on the LWC display:

@AuraEnabled
    public static String getInstance() {
        string url = URL.getSalesforceBaseUrl().toString();
        return url;
    }

 

We are using the login.salesforce.com to open the page as specified in the Web Server Flow documentation, does this now need to be the customers org url ? e.g. https://{{customer}}.my.salesforce.com

Is anyone else haing this issue?

Best Answer chosen by Ryan Avent 14
Ryan Avent 14Ryan Avent 14
Answer is yes you need to use the true site url in winter 23