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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

creating adobe access token in a headless action

ursboller
Community Advisor
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
duypnguyen
Correct answer by
Employee
Employee

Hi @ursboller@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
duypnguyen
Employee
Employee
Hi @ursboller , 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.
ursboller
Community Advisor
Community Advisor
@duypnguyen thanks for confirmation and link to the issue. I hope there is a fix soon ...
duypnguyen
Correct answer by
Employee
Employee

Hi @ursboller@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

ursboller
Community Advisor
Community Advisor
Hi @duypnguyen thanks for the update! I will give it a try later today ...
ursboller
Community Advisor
Community Advisor
@duypnguyen I changed my code to use the updated aio-lib-ims and it works as expected. thanks for the update!
1982luca
Level 8
Level 8
@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?
duypnguyen
Employee
Employee
@1982luca - 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?