Leiste mit Community-Erfolgen erweitern.

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

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?

Themen

Anhand von Themen werden Community-Inhalte kategorisiert und Sie können so relevanten Inhalt besser finden.

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
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-----".

Lösung in ursprünglichem Beitrag anzeigen

8 Antworten

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

Korrekte Antwort von
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
Hi @duypnguyen thanks for the update! I will give it a try later today ...

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

Employee
awesome, thank you for confirming!

Avatar

Level 9
@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?