Automate JWT Token Generation | Community
Skip to main content
ambikaTewari_ATCI
Community Advisor
Community Advisor
October 28, 2022
Solved

Automate JWT Token Generation

  • October 28, 2022
  • 3 replies
  • 2075 views

Hi Team,

 

We are planning to use Recommendations API to create/update Entities. 

For those API to run we need bearer token, bearer token is generated using JWT Token.

 

Both bearer and jwt token are not constant so how can we automate it ?

 

Any insight on this is reallly helpful.

 

 

 

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 Rajneesh_Gautam_

@ambikatewari_atci  - I provided Python code to generate JWT and Access token (https://experienceleaguecommunities.adobe.com/t5/adobe-target-questions/generating-jwt-for-target-api/m-p/317997#M1643)  - is this what you are after?

 

Regards

Rajneesh

3 replies

ambikaTewari_ATCI
Community Advisor
Community Advisor
October 28, 2022

Found this https://developer.adobe.com/developer-console/docs/guides/authentication/JWT/samples/

 

does it talk about the script (in different languages) to programmatically automate the JWT token ?

Perrin_Ennen
Community Advisor
Community Advisor
October 28, 2022

You can use client secrets to generate a new bearer token each time before the API request.

 

There are several scripts - for JWT encode and decode. Depending on which language you want to use.

I myself use this automated in combination with CI/CD pipelines with docker images and in bash.

ambikaTewari_ATCI
Community Advisor
Community Advisor
October 31, 2022

Hi @perrin_ennen  in order to generate the bearer token (to used in API) I would need JWT token.

JWT token has the expiry so how do I generate it programmatically using keys ?

API Team doesnt have the UI access but I can share with them the API and private key.

Perrin_Ennen
Community Advisor
Community Advisor
November 2, 2022

You can do the JWT token generation manually in the UI. But it is also possible to automate this yourself.

 

Here is an article how it works with Bash: Generate JWT With Bash 

Something like this exists for other programming languages as well.

Rajneesh_Gautam_
Community Advisor
Rajneesh_Gautam_Community AdvisorAccepted solution
Community Advisor
November 6, 2022

@ambikatewari_atci  - I provided Python code to generate JWT and Access token (https://experienceleaguecommunities.adobe.com/t5/adobe-target-questions/generating-jwt-for-target-api/m-p/317997#M1643)  - is this what you are after?

 

Regards

Rajneesh

ambikaTewari_ATCI
Community Advisor
Community Advisor
November 8, 2022

yes @rajneesh_gautam_ I'll try this.

 I got this help doc (https://developer.adobe.com/developer-console/docs/guides/authentication/JWT/samples/) also which talks about the scripts in different languages to automate the JWT generation .