cancel
Showing results for 
Search instead for 
Did you mean: 

Create JWT Token in SAP CAPM

kowsalyaa
Discoverer
0 Kudos

Hello All,
I'm trying to call an API deployed in a global account from a different subaccount. I've created a destination to store the details of the deployed API in the global account. The deployed API requires a JWT token for authorization. I'm using the
jsonwebtoken library to create a JWT token and passing it to the API using Axios. However, I'm getting the error "Jwt issuer is not configured."

CAPM experts, please advise on what needs to be changed in my code. Attaching the code below

I have the client details and url from the destination

       const payload = {
                iss: clientId,
                sub: clientId,
                aud: destination.originalProperties.tokenServiceURL,
                iat: Math.floor(Date.now() / 1000),
                exp: Math.floor(Date.now() / 1000) + 3600,
            };

            const token = jwt.sign(payload, privateKey, { algorithm: 'HS256'});
            console.log(token);
            console.log('TOKEN', token);
            const headers = {
                'Authorization': `Bearer ${token}`
            };
            const payload = {
               //payload here
            }
            let response = await axios.post(`${destination.url}`, payload, {
                headers: {
                    ...headers,
                },
            });
 
Thanks & Regards,
Kowsalyaa 

Accepted Solutions (0)

Answers (0)