creating adobe access token in a headless action

ursboller

MVP

31-08-2020

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?

Accepted Solutions (1)

Accepted Solutions (1)

duypnguyen

Employee

23-09-2020

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

Answers (0)