creating adobe access token in a headless action | Community
Skip to main content
Urs_Boller
Community Advisor
Community Advisor
August 31, 2020
Solved

creating adobe access token in a headless action

  • August 31, 2020
  • 3 replies
  • 2510 views

I try to create an adobe access token in a headless action. first I tryed to use aio-lib-ims but this fails to include in the action (maybe an issue with the core library and their dependencies?)

 

is there any easy way to create an adobe access token having all data in the .env file?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by duynguyen_adobe

Hi @urs_boller@oliverf82757722 - a new version of @adobe/aio-lib-ims has been released, which fixes the issue reported earlier. I was able to get the token using this code.

const { context, getToken } = require('@adobe/aio-lib-ims') const config = { client_id: params.client_id, client_secret: params.client_secret, technical_account_email: params.technical_account_email, technical_account_id: params.technical_account_id, meta_scopes: [ 'ent_campaign_sdk' ], ims_org_id: params.ims_org_id, private_key: params.private_key }; await context.set('my_acs', config) await context.setCurrent('my_acs') // get JWT access token const token = await getToken() // initialize the sdk const campaignClient = await CampaignStandard.init(params.tenant, params.client_id, token)

Please note that, for the value of private key, you could pass a string in this format: "-----BEGIN PRIVATE KEY-----\nmy\nprivate\nkey\n-----END PRIVATE KEY-----".

3 replies

Adobe Employee
September 1, 2020
Hi @urs_boller , thanks for the issue report. We have an github issue for tracking purpose here: https://github.com/adobe/aio-lib-ims/issues/55. We are prioritizing the fix and will update here when it is fixed.
Urs_Boller
Community Advisor
Community Advisor
September 1, 2020
@duynguyen_adobe thanks for confirmation and link to the issue. I hope there is a fix soon ...
duynguyen_adobeAdobe EmployeeAccepted solution
Adobe Employee
September 23, 2020

Hi @urs_boller@oliverf82757722 - a new version of @adobe/aio-lib-ims has been released, which fixes the issue reported earlier. I was able to get the token using this code.

const { context, getToken } = require('@adobe/aio-lib-ims') const config = { client_id: params.client_id, client_secret: params.client_secret, technical_account_email: params.technical_account_email, technical_account_id: params.technical_account_id, meta_scopes: [ 'ent_campaign_sdk' ], ims_org_id: params.ims_org_id, private_key: params.private_key }; await context.set('my_acs', config) await context.setCurrent('my_acs') // get JWT access token const token = await getToken() // initialize the sdk const campaignClient = await CampaignStandard.init(params.tenant, params.client_id, token)

Please note that, for the value of private key, you could pass a string in this format: "-----BEGIN PRIVATE KEY-----\nmy\nprivate\nkey\n-----END PRIVATE KEY-----".

Luca_Lattarini
January 31, 2021
@duynguyen_adobe @duynguyen_adobe I am following the code above and I am getting ->Cannot resolve module "@adobe/aio-lib-ims". Basically , the issue comes fromrequire('@adobe/aio-lib-ims'); I am implementing that inside ->'use strict'; module.exports = async function () {} Any siuggestion?