JWT Connection

This connection implements JWT authentication.

Properties

Option

Type

Default

Description

Option

Type

Default

Description

id

string

 

ID of the connection.

url

string

 

Base URL of the connection. A full path must be provided (e.g.: https://...).

headers

java.util.Map

 

Custom headers.

certificateName

string

 

Name of the certificate.

authUrl

string

 

Endpoint used for authentication purposes. This is often a separate endpoint which provides a token for further calls. A full path must be provided (e.g.: https://https://login.salesforce.com/services/oauth2/token).

authRequestHeaderBearer

string

Bearer

Prefix used in the authentication request header. Usually, the value is 'Bearer' in this kind of authentication.

authRequestHeader

string

Authentication

Header used for authentication.

authRequestContentType

string

 

Content type of authentication request. This should adhere to the server requirements. Usually, 'application/x-www-form-urlencoded' is used for OAuth2-based authentications, whereas 'application/json' is used for JWT-based authentications.

authResponseTokenKey

string

 

Defines a key from which a token is parsed. E.g. if auth response is {'token': ‘aaa', 'expires':'155555'}, the actual token is in the 'token' key, thus the value of the field is 'token’.

authResponseExpirationKey

string

 

Token validity is often limited. If the response returns the token expiration, the key will be parsed and re-authentication will be automatically made once the token expires. E.g. if auth response is {'token': 'aaa', 'expires':'155555'}, the actual token is in the 'expires' key, thus the value of the field is 'expires'. The token will be automatically refreshed in 155555 milliseconds.

authResponseExpirationKeyLocation

string

 

Defines location of the field 'expires_in' (or other selected) when it is returned. The options are: body_json, body_plaintext, header_json, header_plaintext. E.g. body_json means that 'expires' is located in the JSON response body. Possible values are: body_json, body_property_based, header_json, header_plaintext.

reAuthOnCodes

string

 

When a list of values separated by a comma is defined, whenever a certain code form list is returned from any request, the authorization is called again. This occurs for example in Salesforce. Example value: 400,401,404.

authExpirationMultiplier

string

 

Token expiration is handled in milliseconds by default. Specify a multiplier if the unit is different (1=ms, 1000=s, ...).

username

string

 

Username for basic authentication.

password

string

 

Password for basic authentication.

authRequestTemplate

 

 

 

Examples

Define a new connection:

<bean id="basicConn" class="net.pricefx.integration.component.rest.domain.connection.JwtConnection"> <property name="url" value="https://thecompany.com"/> <property name="authUrl" value="https://thecompany.com/auth" <property name="authRequestHeaderBearer" value="Pricefx"/> <property name="authRequestHeader" value="PartitionX"/> <property name="username" value="pasta"/> <property name="password" value="rasta"/> </bean>

Use it in a route:

<route id="opendata2-create"> <from uri="direct:create"/> <to uri="pfx-rest:post?uri=/A_SalesOrder&amp;connection=basicConn"/> <to uri="mock:create"/> </route>

Results:

  • Request to https://thecompany.com/auth is done, auth response is parsed according to the properties definition. The token is extracted, expiration is extracted.

IntegrationManager version 5.8.0