thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.72k stars 829 forks source link

[HELP] API rest OAuth 2 #1159

Open emurilloEcourbes opened 1 year ago

emurilloEcourbes commented 1 year ago

Description I have a device where I pull the data using API Rest. The API uses OAuth 2 with the client credentials flow

For obtaining the token, I execute a POST request to the provided address (e.g. /api/token) The request headers must contain: Accept: application/json The request body must specify the client id, the client secret and the client_credentials grant type

Once I have obtained the token, I must supply it in each API call. The request headers must contain:

Accept: application/json Authorization: Bearer {token}

I don't know how to do it in the IOT gateway.

Environment

OS: Ubuntu ThingsBoard: 3.5.1 Browser: Chrome

samson0v commented 1 year ago

Hi @emurilloEcourbes, thanks for your interest in ThingsBoard IoT Gateway! If you using Request Connector, you can use httpHeaders config parameter and configuration will look like:

image

More information about Request Connector in the official documentation.

emurilloEcourbes commented 1 year ago

Thnaks @samson0v for your reply. In my case the token expires in 3600 seconds, it's a third party application so I can not modify it. What is the best way to refresh the do it?