How to Authenticate with External JSON Web Token - Salesforce Example

Now it is possible to authenticate Pricefx partition with an external JWT token.

Here is a step-by-step guide how to set it up in the Salesforce.

Salesforce: Create New Certificate

You need a certificate with the Key Size 2048.

 

Pricefx: Create Configuration for External JWT Tokens

  1. Download a certificate from the Salesforce and export the public key from it.

    openssl x509 -pubkey -noout -in pricefx_jwt_2048.crt > pricefx_jwt_2048.pubkey
  2. Create one line string from the public key.

    awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' pricefx_jwt_2048.pubkey
  3. Take the output and create a new configuration input in the Advanced Configuration Section with the name externalJWTConfiguration and put the public key there and set the permissions.

    { "entries" : { "salesforceScratch" : { "publicKey" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjeJy7gBcWkF1PkTyjbtX\n7SNWVpWujDEZ3PrMx7a2B7y/wAb7lB40ROY4hoImM9QxcwBRaEU2kNtWqvyaUY7N\nYdqXSH+Qa75oBCCvtjjZJxO/vDz9rMyu7fQlU7nPJM8yly7c5E2TvcEWQMjbL6Yn\nbuwNPlBbzAi3u5lMf4pISvswV4aSs6X4rFg3cQTDlctKpv3FULv701ZD7Oqu14cJ\nRikCM253Am0+3KPGxmX+vdhNI9oEMt7eIEvWh+ky5p7hZTdV8s+mez/y5JnTkcy/\nwuhMmQ5Nkp2yJV217JsILNW2EZZDKz0zTIjfD7VlzsL0dzIUm+LQHyr4QdrpzW0u\nlwIDAQAB\n-----END PUBLIC KEY-----\n", "permissions" : ["PRICINGFORMULA_EXECUTE"] } } }

 

Salesforce: Make Call to Pricefx Endpoint

  1. Generate named credentials with no authentication.

    1. Put there the URL you want to call.

       

  2. Write the Apex Code that will authorize with JWT Token.

     

  3. Call the APEX code and see the debug in the Salesforce Develop Console.

  4. You can validate the JWT token.

See also: https://ambassadorpatryk.com/2020/07/secure-calls-from-salesforce-to-mulesoft-with-jwt/

Found an issue in documentation? Write to us.