API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
Expand all | Collapse all

How to use user defied validity period(token expiry time) in JWT-generate

  • 1.  How to use user defied validity period(token expiry time) in JWT-generate

    Posted Thu March 13, 2025 12:36 PM

    Hi Team,

    I have some requirement to generate custom token expiration time(Validity period) instead of using static value in sec of JWT-generate token in APIC.

    User is going to send this token expiration sec in input data and same need to taken as jwt-generate action and generate token based on this instead of static value given in Validity Period(sec).

    Thanks in advance.



    ------------------------------
    Sunil Kumar Sure

    ------------------------------


  • 2.  RE: How to use user defied validity period(token expiry time) in JWT-generate

    Posted Thu March 27, 2025 04:26 PM

    Hello Sunil,

    You can use context variables as policy inputs, by using the $() notation. Set the desired expiration in a context variable with the set-variable policy, or in gatewayscript and then use this variable as input for the jwt-generate policy's exp-claim field.

    Alternatively, you could use the Datapower jwt module, described in https://www.ibm.com/docs/en/datapower-gateway/10.6.x?topic=apis-jwt-module, which can be imported into a gatewayscript policy.

    Hope that helps



    ------------------------------
    Hindrik Brouwer
    ------------------------------



  • 3.  RE: How to use user defied validity period(token expiry time) in JWT-generate

    Posted Tue April 01, 2025 03:50 AM
    Edited by Sunil kumar Sure Tue April 01, 2025 04:45 AM

    Hi Hindrik Brouwer,

    Thank you for your quick reply, unfortunately jwt-generate policy's exp-claim field is not exposed to get from any context variable, it's fixed value which need to pass as sec. I am trying Datapower jwt module and let you know outcome.



    ------------------------------
    Sunil Kumar Sure