Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

creating adobe access token in a headless action

Avatar

Community Advisor

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?

1 Accepted Solution

Avatar

Correct answer by
Employee

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-----".

View solution in original post

8 Replies

Avatar

Employee
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.

Avatar

Community Advisor
@duypnguyen thanks for confirmation and link to the issue. I hope there is a fix soon ...

Avatar

Correct answer by
Employee

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-----".

Avatar

Community Advisor
@duypnguyen I changed my code to use the updated aio-lib-ims and it works as expected. thanks for the update!

Avatar

Community Advisor
@duypnguyen @duypnguyen 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?

Avatar

Employee
@Luca_Lattarini - could you try adding this `@adobe/aio-lib-ims` to the list of dependencies in package.json file, then `npm install`, and redeploy your app?