4

I am working on custom activity where I need to identify the account (user) details from which the request came to the custom activity REST APIs.

I thought setting "useJwt": true in the config.json will send the account details but it only sends the activity API parameters in the JWT token.

I have used the JWT token received in POST body of the Hub Exchange app to retrieve the account details as explained in the docs: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-app-development.meta/mc-app-development/explanation-decoded-jwt.htm

But, for custom activity I can't able to find a way to get the account details as I got in Hub Exchange API.

config.json

{
  "workflowApiVersion": "1.1",
  "metaData": {
    "icon": "img/img_1.png",
    "iconSmall": "img/img_2.png",
    "category": "message"
  },
  "type": "REST",
  "lang": {
    "en-US": {
      "name": "Test custom activity",
      "description": "Testing custom activity"
    }
  },
  "arguments": {
    "execute": {
      "inArguments": [
        {
          "firstName": "{{Contact.Attribute.DE_NAME.FirstName}}"
        },
        {
          "lastName": "{{Contact.Attribute.DE_NAME.LastName}}"
        },
        {
          "emailAddress": "{{Contact.Default.Email}}"
        }
      ],
      "outArguments": [],
      "url": "https://xyz.ngrok.io/activities/execute",
      "verb": "POST",
      "body": "",
      "header": "",
      "format": "json",
      "useJwt": true,
      "timeout": 10000
    }
  },
  "configurationArguments": {
    "applicationExtensionKey": "test-activity-custm-wwq",
    "defaults": {
      "activity": "0"
    },
    "save": {
      "url": "https://xyz.ngrok.io/activities/save",
      "useJwt": true
    },
    "publish": {
      "url": "https://xyz.ngrok.io/activities/publish",
      "verb": "POST",
      "body": "",
      "useJwt": true
    },
    "validate": {
      "url": "https://xyz.ngrok.io/activities/validate",
      "verb": "POST",
      "body": "",
      "useJwt": true
    },
    "stop": {
      "url": "https://xyz.ngrok.io/activities/stop",
      "useJwt": true
    }
  },
  "wizardSteps": [
    {
      "label": "Select anything",
      "key": "1"
    },
    {
      "label": "Confirm Settings",
      "key": "2"
    },
    {
      "label": "Save Settings",
      "key": "3",
      "active": false
    }
  ],
  "userInterfaces": {
    "configModal": {
      "height": 250,
      "width": 600,
      "fullscreen": false
    }
  }
}

Please help me to get account details of the account requesting the custom activity API.

Thanks.

4
  • You will only ever be able to use the custom activity in one mid.. so what the point for this use case? Can't you just hard Code it? Jul 18 '17 at 11:30
  • 1
    I need publish the custom activity in app center and allow other users to use this activity. There will seperate options for each user. For proving the user specific option I need to identify the user(account) who use this activity. Please tell me how to achieve this.
    – Gokul
    Jul 18 '17 at 11:33
  • @Data_Kid, Please tell me whether this use case is possible?
    – Gokul
    Jul 18 '17 at 12:14
  • Not sure so don't wanna put my foot in my mouth. Struggling to see why you would need to expose this data but I will let one of the marketing cloud sages take this Jul 18 '17 at 12:18
2

I finally got the user details using the Postmonger event requestTokens and requestedTokens which I found in this Stack Exchange answer.

connection.on('requestedTokens', function(tokens) { ... });

Then, using the fuel2token received in the tokens parameter of requestedTokens event, I got the user details using the GetTokenContext REST API.

4
  • 1
    GET /platform/v1/tokenContext only returns the userId. Have you managed to obtain other information such as emailaddress?
    – Ranga
    Feb 5 '19 at 8:01
  • Exactly what I was looking for. Though I needed more info like email address, but I will manage with user.id. Jan 27 at 14:20
  • How did you get the custom subdomain part for the endpoint url? Jan 29 at 9:51
  • @MohitBhardwaj did you figure out how to get the custom subdomain part? I am integrating with multiple customers and I need a way to figure out which subdomain I should be using to get the token context
    – digiarnie
    Jun 18 at 7:33

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.