Score:0

When we inplement the recaptcha enterprise in Salesforce Marketing Cloud cloudpages, we found we can't use the service account to do the auth

es flag

When we inplement the recaptcha enterprise in Salesforce Marketing Cloud cloudpages, we found we can't use the service account to do the auth2.0 authorization. Do we need use the API KEY method? If yes, we see the document with API KEY call still need "Note: This API request requires an authorization token from the Cloud SDK, which is generated by the gcloud auth application-default print-access-token command. Ensure you have set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path for your service account private key file." How can we use the ssjs or javascript code to generate the oauth token to call the api?

Maybe the most import point is:

  1. Whether salesforce marketing cloud suppor service account auth( maybe not)?
  2. If yes, how to do the implement with ssjs or javascript
  3. If no, whether we need use the api_key to do the auth?
  4. If use the api_key to do the auth, whetehr need the auth token(oauth2.0), can we have some sample code to reference with ssjs or javascript or ampscript?

We use https://jwt.io/ to generate the token with public key and private key, but get the unauth error. jwt postman error

Score:0
cn flag

The Google Cloud CLI has a command-line option to add scopes to the access token.

How can we use the ssjs or javascript code to generate the oauth token to call the API?

Use the Google Cloud Node.js SDK. The auth section has APIs for creating access tokens from service account JSON key files. The SDK has numerous examples.

Security note: Do not create credentials in the browser. Only creating credentials on a server you control. In the browser, end-users can access your private key granting them rights to your account. Private keys do not expire.

Note regarding jwt.io and Postman. Creating a Google OAuth Access Token is a two-step process. First, you create a signed JWT and then exchange the signed JWT for the token. I do not recommend posting your private key on websites, which would be required to use jwt.io to sign your JWT.

user1013745 avatar
es flag
Hi, John. Thanks for your response. As we using the Salesforce Marketing Cloud, We can't install the SDK. Also can't set the enviroment path. Can we use the API key to get the request? This whether need a acess token?
John Hanley avatar
cn flag
As the error message stated, you must use an OAuth token. I would deploy another service in Google Cloud, such as Cloud Run or Functions, to make the requests for my code running in Salesforce.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.