Authorization
To access the REST API, you will need to have a valid OTbase Inventory account. This account can either be an account associated with a specific individual or a dedicated account created specifically for a third-party software application that wishes to interact with the OTbase system (recommended).
Using A Dedicated API User Account
The benefit to creating a dedicated account for third-party applications is that it allows you to set certain boundaries and restrictions on what data can be accessed by the third-party application. This can be achieved by clearly defining and setting access rights within the OTbase Inventory user management system. For instance, it is possible to limit the scope of a given account to only allow access to inventory data of a specific site, building, or group of devices.
Authentication
OTbase uses a type of authentication known as Basic Authentication. The term basic here refers to the fact that the access credentials are transmitted straight to the OTbase system, without the involvement of any independent agents or cryptography. However, it is important to note that this does not mean that the credentials are transmitted in plain text. In fact, when connecting to the OTbase system, it is recommended to use HTTPS to ensure secure transmission of data. Therefore, to be able to use the REST API in OTbase, it is necessary to set up your third-party application for "basic authentication" and provide the necessary credentials for a valid user account within the OTbase system.
Setting up Authentication In Python
To set up basic authentication using the Python Requests library, you can pass a tuple of username and password to the auth
parameter of the requests.get()
method. For example, if the username is "myusername" and the password is "mypassword", you can make a request to a URL as follows:
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1)
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials
auth=('username', 'password')
url = 'https://'+hostname+'/ot-base/api/v1/devices'
response = requests.get(url, auth=auth)
print(response.text)
Setting Up Authentication In Postman
With our Postman collection, we've done the configuration for you. All you need to do is enter in your host name (the URL or IP address of your OTbase Inventory installation) and credentials.
Comments
0 comments
Please sign in to leave a comment.