-3

Basically, I do not want anyone to be able to access my Landing page. I only want salesforce marketing cloud users to be able to access the Landing Page.

So, if anyone tried to access the Landing page by going to the URL, they should get a login screen that requires a marketing cloud login credential.

I have noticed that once I have created Landing Page, and URL generated, I can use this landing page by URL anywhere. Because It's a public URL. I want to make this URL Private. 

Is this feasible?

4
  • 1
    There is no native way of restricting access to cloud pages. But have you tried googling? There are few solutions out there, which might be useful for you. Oct 4 at 15:18
  • @LukasLunow Yes, I have done some googling. Got something but not that I want. 1. First Private Domain configured and get SSL certification. Enable this from support and use it when we create a Landing page. But this is not related to our use-case.
    – Rahul
    Oct 5 at 4:35
  • @LukasLunow 2. Second, can I use PURLs? I don't have much idea about that. But whatever I understand from google, For this feature we have to raise a case on support. And by using PURLs, we can personalized Landing pages URL with Subscriber key or First Name. I am confused is this will work for me or not. do you have any idea about it?
    – Rahul
    Oct 5 at 4:35
  • 1
    Neither of the things you list have anything to do with restricting access. Additionally, PURL is a legacy feature, no longer applicable. Please have a look at this, this and this Oct 5 at 11:56
0

You can achieve this by creating an installed package with a web app integration component, that will allow you use authorization code flow to check if a visitor of your Cloud Page is a Marketing Cloud user. If they are not already logged into Marketing Cloud upon visiting the Cloud Page, they will be redirected to the login screen and they content of the Cloud Page won’t be displayed unless they successfully log into Marketing Cloud. Below are the steps to implement this solution.

First create an installed package:

  1. In Marketing Cloud, go to Setup > Apps > Installed Packages.
  2. Click New.
  3. Give the package a name and description.
  4. Save the package.
  5. Under Components, click Add Component, and select an API Integration component.
  6. Under Integration Type, choose Web App and click next.
  7. Under Redirect URIs, paste the link to the CloudPage that hosts your app.
  8. The scope is not required, so leave all checkboxes blank. Save the package.

And then add this script at the top of your Cloud Page (remember to fill in all the missing information from the installed package):

<script runat="server">

Platform.Load("core", "1");



var client_id = "xxxxx",        //add the client id from the installed package

    client_secret = "xxxxxx",    //add the client secret from the installed package

    subdomain = "xxxxx",        //add the 28 character subdomain (starts with mc….)

    redirect_uri = "xxxxx";     //add the url of the CloudPage that hosts your app



var auth = true;



var authToken = Platform.Request.GetCookieValue("authToken");

if (authToken == null) {

    var authCode = Request.GetQueryStringParameter("code");

    if (authCode == null) {

        Platform.Response.Redirect('https://&#39; + subdomain + '.auth.marketingcloudapis.com/v2/authorize?response_type=code&client_id=' + client_id + '&redirect_uri=' + redirect_uri);

    } else {

        var url = 'https://&#39; + subdomain + '.auth.marketingcloudapis.com/v2/token'

        var contentType = "application/json";

        var payload = {

            "grant_type": "authorization_code",

            "code": authCode,

            "client_id": client_id,

            "client_secret": client_secret,

            "redirect_uri": redirect_uri

        };

        try {

            var accessTokenRequest = HTTP.Post(url, contentType, Stringify(payload));



            if (accessTokenRequest.StatusCode == 200) {

                var tokenResponse = Platform.Function.ParseJSON(accessTokenRequest.Response[0]);

                var accessToken = tokenResponse.accessToken;

                Platform.Response.SetCookie("authToken", accessToken);

                auth = true;

            }



        } catch (error) {

            auth = false;

        }

    }

}

</script>

For more details, see here: https://sfmarketing.cloud/2021/08/09/securing-marketing-cloud-apps-hosted-on-cloudpages/

Not the answer you're looking for? Browse other questions tagged or ask your own question.