How to generate JWT token using Rest API for Oracle fusion ERP Cloud in Java

2.3k views Asked by At

In Oracle ERP cloud we can login via Rest API using JWT authentication i.e. Bearer Token in PostMan.

So to generate this JWT token through browser I don't need much effort I just need hit below in my browser : https:///fscmRestApi/tokenrelay

I will get token something like this :

principal    "User_Name"
expires_in    14400000
token_type    "JWT"
access_token    "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsIng1dCI6Ik9aOVBxbnotd0xraERLclQwSEhBVDFVWE1GQSIsImtpZCI6InRydXN0c2VydmljZSJ9.eyJleHAiOjE1NDkwMzEzMzcsInN1YiI6IlNBTEVTX0FETUlOIi
wiaXNzIjoid3d3Lm9yYWNsZS5jb20iLCJwcm4iOiJTQUxFU19BRE1JTiIsImlhdCI6MTU0OTAxNjkzN30.iyehNURzZ6drKwrZ30wLMgjWZvNHjtPquB4OqY1URrjb7h_rbaSXyGHVjF83unThl4P9YDc2soTaTtyBTsEdnjHdbmhyTyNeJsaX
iyId9kQRc8aY7FKjc_KN0B4W4ehiZDz_C5Ju0Wj0Zbnws5ps0neBekKaBjz_QQOGKwpHPxcvJff4MqsCeLPZd3e7SdjY3mcOizkfaQergQY--pEYeGPqzmTaz_oTtDKrkG3DatRrWOPnlb4-I6TsYI9ccVxVshZMfhf9O0vP54SvDMfb56Vl3
FP-idskXXYoVVa0artLDE-0_npE0tGZdK-EvHmcyLcJsE7hvv2QnfDFnng"

Very Cool....

but I would like to generate this token via Java code / PostMan and not by browser as this will expire after its expiry time.

Basically I want implement JWT for Oracle ERP cloud, we have something like below in our oracle ERP cloud UI

Tools > Security Console > API Authentication.

I know we have to generate hash code using Base64 method but then then what other thing will required to generate token like above via Java/Rest API

enter image description here

1

There are 1 answers

0
Gerard Otín On

if you're using APEX, you can use APEX_JWT API from Oracle DB. In Java, you can use one of libraries published in jwt.io to generate a JWT.