0

I have created a API package under Setup -> Installed Packages.

I have created API Integration component for the package .I have the below basic details for the component.

  • Client Id
  • Client Secret
  • Authentication Base URI
  • REST Base URI

I want to test the created API package using any tool( Postman or other API testing tools).

I was able to find API integration testing links for SFDC but not for the Marketing Cloud.

What is the redirect URL to be used in the API package? I have created an API integration package of Integration type ( Web APP)

In web app properties, what is the redirect URL to be provided?

2 Answers 2

11

The most basic way to test it is to authenticate using POSTMAN:

Based on the package you installed, use the correct endpoint specified in the Installed Package:

For v1: POST: https://xxxxx.auth.marketingcloudapis.com/v1/requestToken

For v2: POST: https://xxxxx.auth.marketingcloudapis.com/v2/token

In the body select raw/JSON (application/json) and include Grant Type, the Client Id and Secret for v2 or just Client Id and Secret for v1. Request for v1:

{
  "clientId": "...",
  "clientSecret": "..."
}

Request for v2:

{
  "grant_type":"client_credentials",
  "client_id":"...",
  "client_secret": "..."
}

More info here:

v1: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-getting-started.meta/mc-getting-started/get-access-token.htm

v2: https://developer.salesforce.com/docs/atlas.en-us.mc-app-development.meta/mc-app-development/access-token-s2s.htm

1
1

Web app and public app integrations allow applications to integrate with Marketing Cloud on behalf of an end-user, using the intersection of the app’s and user’s permissions. A public app can’t securely store a client secret, but a web app can.

Use the authorization code grant type to allow your web or public app to access Marketing Cloud resources on behalf of a user.

It can take up to five minutes before authorization codes, access tokens, and refresh tokens generated by the v2/authorize and v2/token endpoints incorporate any changes made to the API integration in Installed Packages.

Authorization Code Request

JSON Parameters

{
 "response_type": "code"
 "redirect_uri": "Must match a redirect URL specified on the API integration in 
   Installed Packages. The URL must be encoded for this request."
 "clientId": "YOUR_SECURE_STORED_ID",
 "clientSecret": "YOUR_SECURE_STORED_KEY",
 "state": "",
  "scope": "",

}

Example Request URL

https://YOUR_SUBDOMAIN.auth.marketingcloudapis.com/v2/authorize?response_type=code&client_id=vqwyswrlzzfk024ivr682esb&redirect_uri=https%3A%2F%2F127.0.0.1%3A80%2F&scope=email_read%20email_write%20email_send&state=mystate

Example Web App Request

Host: https://YOUR_SUBDOMAIN.auth.marketingcloudapis.com
POST /v2/token
Content-Type: application/json

{
  "grant_type": "authorization_code",
  "code": "code received",
  "clientId": "YOUR_SECURE_STORED_ID",
  "clientSecret": "YOUR_SECURE_STORED_KEY",
  "redirect_uri": "https://127.0.0.1:80/",
  "scope": "email_read email_write email_send offline"
}

Example Web App and Public App Response

HTTP/1.1 200 OK
{
   "access_token":"code retrieved",
   "refresh_token":"new token",
   "expires_in":1200,
   "token_type":"Bearer",
   "rest_instance_url":"YOUR_SUBDOMAIN.rest.marketingcloudapis.com",
   "soap_instance_url":"YOUR_SUBDOMAIN.soap.marketingcloudapis.com",
   "scope": "email_read email_write email_send offline"
}

Example Error Response

HTTP/1.1 401 Unauthorized
{
"error": "unauthorized_client"
"error_description": "The client is not authorized to request an authorization code using this method."
"error_uri": "https://developer.salesforce.com/docs"
}

Diagram

enter image description here

Further Info https://developer.salesforce.com/docs/atlas.en-us.mc-app-development.meta/mc-app-development/integration-app-auth-code.htm

https://developer.salesforce.com/docs/atlas.en-us.mc-app-development.meta/mc-app-development/authorization-code.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .