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
VSK98VSK98 

Getting error while passing the dynamic url into Auth.SessionManagement.finishLoginFlow

Hello All,

I'm trying to pass the dynamic url into Auth.SessionManagement.finishLoginFlow as i'm getting the error. Please find the snippet code below.

Apex:
public class VisualFlow {

public PageReference getFinishPage() {
 
// Get the query string of the current request.
System.debug('Query: ' + URL.getCurrentRequestUrl().getQuery());
string retUrl = URL.getCurrentRequestUrl().getQuery();
if(retURL == 'retURL=%2Fhome%2Fhome.jsp'){

    return Auth.SessionManagement.finishLoginFlow('/home/home.jsp');
}

else
{
    retURL = retURL.removeStart('retURL=');
    system.debug('retURL####'+retURL);  
return Auth.SessionManagement.finishLoginFlow(retUrl); ------- Getting error
}
}

}

Error:
System.NoAccessException: Invalid Page Redirection: The page you attempted to access has been blocked due to a redirection to an outside website or an improperly coded link or button. Please contact your salesforce.com Administrator for assistance.

I was hiting the url like this "https://*****.my.salesforce.com/001/o" 

please share your thoughts....
Thanks,
​​​​​​​VSK98
VinayVinay (Salesforce Developers) 
Hi,

Review below link and update VF accordingly.

https://trailblazers.salesforce.com/answers?id=9063A000000pc9VQAQ

Thanks,