简体   繁体   中英

Thingsboard REST API - How to impersonate another tenant

When i'm logged in as sysadmin in the Gui, i can use Tenants → Manage Tenant Admins → Login as Tenant Admin to become a specific tenant admin.

How can i accomplish this, using the REST API?

I need to add/remove/modify devices on behalf of serveral tenants.

I tried to authenticate as sysadmin and use /api/tenant/devices hoping to have access to all devices. But this doesn't do the trick.

You have to login via REST API with E-Mail & Password of the desired Tenant Admin: https://thingsboard.io/docs/reference/rest-api/

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"username":"tenant@thingsboard.org", "password":"tenant"}' 'http://THINGSBOARD_URL/api/auth/login'

This will return the JWT Token needed for further API requests eg deleting devices:

Now, you should set 'X-Authorization' header to “Bearer $YOUR_JWT_TOKEN”. Make sure you use main JWT token and not the refresh token.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM