How to connect OData connector with JWT token authentication?
Steps to perform JWT authentication for any Web API data source
Go to the Data Sources page. Then click the "Create Data Source" button. After clicking, the NEW DATA SOURCE configuration panel opens. Follow the below steps to create a web data source:
- Enter a name and description (optional) for the data source.
- Enter a valid REST API endpoint (or valid OData table endpoint) in the URL text box.
- Choose one of the method types from the combo box for the provided REST API. The options are GET and POST.
- If required by the REST API, provide key-value pairs in headers. For JWT token authentication, add the authorization header.
Authorization: Bearer <default jwt_token>
- Choose a Data Format from the combo box based on the response of your provided REST API. Options are JSON, CSV, and XML.
- Choose an Authentication Type supported by the data source. Options are Basic http authentication and None. Learn more about Authentication Types.
Preview and Connect
- Click Preview & Connect to connect with the configurations set.
- The Choose Table(s) dialog opens. The schema represents the key fields of data retrieved from Web Rest API request. This dialog displays a list of schemas in treeview and its corresponding values in grid for preview. Select required schema(s) from treeview to use in designer and click Connect.
- User can create the dashboard Parameter at data source level. The dashboard parameter icon is provided as shown in the following image.
Open the Dashboard Parameter window. A default parameter will be added as follows.
Set the Parameter1 and name to a proper one, say JWT token and mode as literal and type as string and value is the default user’s JWT token value.
Once you provided the parameter value and save this parameter and save the data source
Edit the data source and configure dynamic parameter for Authorization header
You can edit a data connection using the following steps:
- Click the Data Source button in the configuration panel.
Select a data source listed in the data panel that you need to edit.
Click the highlighted icon to edit the selected data source connection.
Now, the respective data source will be opened in the data design view to handle the modification.
Click the Edit Connection in the data design window toolbar.
Now, the Edit Connection dialog opens.
Change the Authorization header and set JWT parameter as value. Reconnect and save the data source.
NOTE: Now the data source’s data will be changed based on the values in the parameter. Parameter can be changed dynamically in dashboard view time.
Design the dashboard with the data source and publish it.
Steps to change the token from embed application
- Provide the filter parameter feature in the embed sample application and provide your created JWT token in the dashboard parameter.
Refer screenshot below: Based on the user, you can generate JWT token and pass it to this parameter, so the dashboard will be having the corresponding user’s data.