How to invoke REST services requiring JSON Web Token(JWT) for authorization using "Invoke REST API" Activity?

How to invoke REST services requiring JSON Web Token(JWT) for authorization using "Invoke REST API" Activity?

book

Article ID: KB0074634

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks Plug-in for REST and JSON 2.1.0

Description

JSON Web Token(JWT) is mostly used for Authorization and securely transmitting data between Server and Clients. To use JWT for Authorization, clients need a JWT token to access the secure API's from the server. Clients get this token from Server by providing the authentication information. Once authentication information is verified by the server, the server returns a JWT token to the client for accessing secured resources. Using this JWT token for authorization, we can invoke secure REST services using "Invoke REST API" Activity.

Issue/Introduction

This article provides a solution to invoke secure REST services requiring JWT token for authorization using REST and JSON Plugin.

Environment

ALL

Resolution

To use the JWT token for authorization, it is needed to send JWT token in the Authorization header of the invoking REST service using the Bearer schema, as shown below:
==========
Authorization: Bearer eyJhbGciOiJIUzI1NuIsInR7bCI6IkpXVCJ9.eyJsb5dnZWRJdmFzIjoiYWRtaM6iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzStaSZS1EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI
==========

To use the Authorization header for JWT token in "Invoke REST API" Activity, please follow the below steps:
1) Go to the Input Editor Tab and add the "Authorization" element of type string under Header. Please refer below screenshot:
Adding Authorization Header under Header Element in Input Editor
 
2) Now go to the Input Tab of "Invoke REST API" Activity then specify the Bearer and token separated by single space in the Input for the field "Authorization" under Header. Please refer below screenshot:
Specifying JWT token in Authorization Header under Input Tab