How to request a JWT token and use it in actions

Hi Andrea,

if your REST API doesn’t follow the OAuth2 specification, then probably the built-in OAuth2 authentication mechanism in the Web Location connector won’t work.

You can do the following:

  1. Set the base URL in the Web Location connector to http://myUrl/api/
  2. Obtain the authorization token by sending Web Request to path oauth2/token (it will be automatically appended to the base URL specified in the web)
  3. Extract the token from the response, make it a column value. At this point you should have a table with 1 row and 1 column with the token value.
  4. Use the “Iterate” action to call another module, and pass the token from a column to that module’s parameter.

Now, in the called module you have a parameter with the token value assigned. Now you can use it in the authorization header:

image

You can prepend "Bearer " either in the calling module, or in a calculated parameter of the called module. Use the “Preview” mode of the Web Request action to see if the Authorization header is formed correctly.