|
| 1 | +--- |
| 2 | +title: SmartREST 1.0 and basic auth |
| 3 | +tags: [Operate, Cumulocity] |
| 4 | +description: Establishing connection with Basic auth and using SmartREST 1.0 |
| 5 | +--- |
| 6 | + |
| 7 | +%%te%% supports basic authentication and [SmartREST 1.0.](https://cumulocity.com/docs/smartrest/smartrest-one/) |
| 8 | +This page explains how to use basic authentication and SmartREST 1.0 with Cumulocity. |
| 9 | + |
| 10 | +:::important |
| 11 | +It is highly recommended to use certificate-based authentication and SmartREST 2.0. |
| 12 | +This guide is intended for users who must use the SmartREST 1.0 for specific reasons. |
| 13 | +::: |
| 14 | + |
| 15 | +## Setting up basic authentication |
| 16 | + |
| 17 | +To use SmartREST 1.0, the authentication mode must be set to `basic` using the `tedge config` CLI tool: |
| 18 | + |
| 19 | +```sh |
| 20 | +sudo tedge config set c8y.auth_mode basic |
| 21 | +``` |
| 22 | + |
| 23 | +Next, provide credentials (username/password) in a credential file formatted as follows. |
| 24 | +The default location of the credentials file is `/etc/tedge/credentials.toml`: |
| 25 | + |
| 26 | +```toml |
| 27 | +[c8y] |
| 28 | +username = "t5678/octocat" |
| 29 | +password = "abcd1234" |
| 30 | +``` |
| 31 | + |
| 32 | +If needed, you can specify a custom location for the credentials file using the `tedge config` CLI tool: |
| 33 | + |
| 34 | +```sh |
| 35 | +sudo tedge config set c8y.credentials_path </custom/path/to/credentials.toml> |
| 36 | +``` |
| 37 | + |
| 38 | +## Configuring the device ID |
| 39 | + |
| 40 | +The device ID must be explicitly set. This ID will be used as the external ID of the device in your Cumulocity tenant. |
| 41 | + |
| 42 | +```sh |
| 43 | +sudo tedge config set device.id <id> |
| 44 | +``` |
| 45 | + |
| 46 | +## Adding SmartREST 1.0 template to %%te%% config |
| 47 | + |
| 48 | +You need to specify all the external IDs of the SmartREST 1.0 templates you plan to use. |
| 49 | +This can be achieved by providing a comma-separated list of the external IDs: |
| 50 | + |
| 51 | +```sh |
| 52 | +sudo tedge config set c8y.smartrest1.templates template-1,template-2 |
| 53 | +``` |
| 54 | + |
| 55 | +Alternatively, you can add the template IDs one by one: |
| 56 | + |
| 57 | +```sh |
| 58 | +sudo tedge config add c8y.smartrest1.templates template-1 |
| 59 | +sudo tedge config add c8y.smartrest1.templates template-2 |
| 60 | +``` |
| 61 | + |
| 62 | +## Connecting to Cumulocity |
| 63 | + |
| 64 | +Before connecting to Cumulocity, ensure the following prerequisites are met: |
| 65 | + |
| 66 | +- The device has already been registered in Cumulocity using the [Bulk Registration API](https://cumulocity.com/docs/device-management-application/registering-devices/#bulk-device-registration). |
| 67 | +- The SmartREST 1.0 templates have been registered in your Cumulocity tenant. |
| 68 | + |
| 69 | +Once these steps are complete, you can connect to Cumulocity: |
| 70 | + |
| 71 | +```sh |
| 72 | +sudo tedge connect c8y |
| 73 | +``` |
0 commit comments