Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Need help to generate the JWT Token using P8 file and Passphrase

Brajesh_Sharma
Kilo Contributor

Dear All,

 

Need help. I am currently working on a scenario where I need to fetch data from Snowflake. They don’t have Oauth for authentication, but they have provided a certificate file with a .p8 extension and a Passphrase. Using a Python script, I have successfully generated a JWT token with the .p8 certificate and Passphrase and have been able to call the Snowflake API by passing the JWT token as the bearer token. Consequently, I can fetch table/view data in the response. I have managed to configure the above setup in Postman without any issues.

 

However, I am now looking to replicate this setup in ServiceNow. Unfortunately, I haven't found any options within ServiceNow to generate the JWT token using .p8 certificates and Passphrase. Could you please assist me in implementing the above configuration in ServiceNow?

 

Your help would be greatly appreciated.

 

Thank you!

7 REPLIES 7

Hi Jitesh,

No.
I am looking for the solution.

Thanks 
Rajesh

No

 

Pavan Srivastav
ServiceNow Employee

To generate a JWT Token using a P8 file and passphrase in ServiceNow, follow these steps:

  1. Upload the Java Key Store (JKS) certificate:

    • Go to All > Multi-Provider SSO > x509 Certificate.
    • Fill in the form, upload your certificate, and provide the keystore password (your passphrase). Submit the form.
  2. Configure a JWT signing key:

    • Navigate to All > System OAuth > JWT Keys.
    • Create a new JWT signing key, assign it to your uploaded keystore, specify the Key ID (optional), select RSA 256 as the signing algorithm, and enter the signing key password (your passphrase). Submit the form.
  3. Create a JWT provider:

    • Go to All > System OAuth > JWT Provider.
    • Add a new provider, set the expiry interval, and select your signing configuration (the JWT signing key you just created). Submit the form.
  4. Generate the JWT Token using the API:

    • Use the following sample script: var jwtAPI = new sn_auth.GlideJWTAPI(); var headerJSON = { "kid": "a1234" }; var header = JSON.stringify(headerJSON); var payloadJSON = { "jti": "testjti", "iss": "testiss", "sub": "testsub" }; var payload = JSON.stringify(payloadJSON); var jwtProviderSysId = "your_jwt_provider_sys_id"; var jwt = jwtAPI.generateJWT(jwtProviderSysId, header, payload); gs.info("JWT:" + jwt);
    • Replace "your_jwt_provider_sys_id" with the Sys ID of your JWT provider ​

This process enables secure JWT token generation for server-to-server authentication using your P8 file and passphrase.

 

 

https://www.servicenow.com/docs/r/yokohama/platform-security/authentication/Scoped-API-generate-JWT....

 

https://www.servicenow.com/docs/r/yokohama/platform-security/authentication/JWT-Bearer-token-support...