Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following command can be used to get an access token

 

Code Block
titleGet a client credential Token
Request:
curl -X POST -H "Content-Type: application/json" \
    -d '{
    "grant_type": "client_credentials",
    "client_id": "CLIENT_ID",
    "client_secret": "CLIENT_SECRET"
}' "https://api.smartenit.io/v2/oauth2/token"
 
 
{
    "access_token": "8eMu7xv7f4pLCVhHRlYmJxLh1kwPkpTKq...",
    "token_type": "Bearer",
    "expires_in": 10800
}

 

 Now using the token the device can be registered:

Code Block
Request:
curl -X POST -H "Content-Type: application/json" \

    -H "Authorization: Bearer 8eMu7xv7f4pLCVhHRlYmJxLh1kwPkpTKq..." \
    -d '{
    "name": "My Wifi device",
    "type": "wifi",
    "interfaces": [
        {
            "name":"wlan0",
            "ip": "192.168.0.10",
            "mac": "85:35:97:76:56:46"
        }
    ],
    "hwId": "85:35:97:76:56:46",
    "components": {}
}' "https://api.smartenit.io/v2/devices/register"

It's important to include the device interfaces information when registering, this will allow users to connect with the devices using a local network.

...