Sample Block

by shradashah


Sample block with authentication

Sample Salesforce Marketing Cloud Content Builder Block using the blocksdk and SSO OAuth.


As a node app

npm install
npm start

One click deployment to heroku:


Environment variables

The node app needs the following env variables set:

  • APP_ID - the app ID or installed package ID so it knows what SSO page to send to
  • APP_SIGNATURE - the app signature or JWT signing secret so it can decode the JWT passed by SSO
  • CLIENT_ID - the client id from the API integration so it can use the auth endpoing to get a token
  • CLIENT_SECRET - the client secret from the API integration so it can use the auth endpoing to get a token

Building your own block from here

# do not fork
git clone <my block name e.g. myblock>
cd <my block name e.g. mybock>
# create your own empty github repository for your new block and copy the clone url for it
git remote set-url origin <your empty repo url>
npm install

Files to edit:

  • src/main.js for your code
  • dist/index.html for your markup
  • package.json for your block name and description
  • to be your own README

To test your changes locally:

npm run build; npm start

Then go to the block tester app and enter http://localhost:3000 in the text field and click a block. You will have to allow unsecure iframes in your bowser (top right in the url bar in Chrome) first.

Once ready to deploy, commit your changes to your repo and click the deploy to heroku button on it.