How to: Use API keys as authentication method

How to: Use API keys as authentication method

Nodegrid enables using different methods for API authentication, they are: ticket, username, and API key. In this guide you will learn how to create an API account and how to query information using the API. 

Adding the API account from GUI 
1. Login to your Nodegrid GUI device as admin
2. Navigate to Security :: Local Accounts and click Add
3. Define the name of the API user
4. In Account Type, select API account 
5. Optional - Define the Account Expiration Date 
6. Select the privilege group for the API user. 

Note: Copy and store the API Key as it will not be possible to recover it after clicking on Save button 
7. Click Save


Retrive information using the API and the API account
You can check the available API options in the API documentation. 


For this demonstration, I'm using "Get access table information". 


As showed in the image, you can use ticket, username and api_key parameters.  For api_key, I'm removing the "ticket:" information and adding "username": "test", "api_key": "GC9kdnyjPnPWCF+qG4KeTzJk3kgZpBTeaw==". The code should look like this for Python: 

import requests
url = 'https://192.168.42.214/api/v1/access/table'
headers = {"username": "test", "api_key": "GC9kdnyjPnPWCF+qG4KeTzJk3kgZpBTeaw==", "Content-Type": "application/json", "accept": "application/json"}
response = requests.get(url, headers=headers,  verify=False)
print("Response Status Code: ", response.status_code)
print("Response: ", response.text)
Note that you must add the address of your device in URL and the path to the API. 

An example using Curl example: 
curl --insecure --request GET 'https://192.168.42.214/api/v1/access/table' --header 'Content-Type: application/json' --header 'username: test' --header 'api_key: GC9kdnyjPnPWCF+qG4KeTzJk3kgZpBTeaw==' --data '{}'





    • Related Articles

    • How to create RSA Keys for IPSec

      Version 0.1 (02 May 2018) Prepare RSA keys In case Raw RSA keys will be used for the IPSec authentication then these keys need to be created before they can be used in the configuration later. Each RSA Key has a private key which needs to be stored ...
    • How to create Pre-shared Keys for IPSec

      Version 0.1 (02 May 2018) Prepare Pre-shared Keys In case Pre-shared Key will be used to authenticate IPSec tunnels, they need to be created on a Nodegrid system before they can be used. To create a Pre-Shared key on a Nodegrid use the below steps. ...
    • How to Configure IPSec Host to Site tunnel with RSA Keys

      Version 0.1 (02 May 2018)  Overview Host to Site configurations are very similar to Host to Host configurations, especially the authentication methods are the same. Added changes to the configurations are the values for rightsourceip and ...
    • IPSec VPN support

      Version 0.1 (02 May 2018) Virtual Private Network (VPN) Overview A Virtual Private Network (VPN) is used to provide a secure means of communication among remote computers across networks, such as the Internet or a public WAN in general. VPN creates ...
    • How to Configure Active Directory or LDAP Authentication Provider

      Version 0.1 (08 May 2018) Overview NodeGrid supports the authentication and authorization of users through different authentication providers, like LDAP. This guide will look at the different authentication options which are available with LDAP or AD ...