IamUtil

DESCRIPTION

This class simplifies interaction with the Nabto Edge Embedded SDK device’s CoAP IAM endpoints.

For instance, it is made simple to invoke the different pairing endpoints - just invoke a simple high level pairing function to pair the client with the connected device and don’t worry about CBOR encoding and decoding.

Read more about the important concept of pairing here: https://docs.nabto.com/developer/guides/concepts/iam/pairing.html

All the most popular IAM device endpoints are wrapped to also allow management of the user profile on the device (own or other users’ if client is in admin role).

Note that the device’s IAM configuration must allow invocation of the different functions and the pairing modes must be enabled at runtime. Read more about that in the general IAM intro here: https://docs.nabto.com/developer/guides/concepts/iam/intro.html

DECLARATION

public class IamUtil 

EXAMPLE

    func invoke() throws {
        let client = NabtoEdgeClient.Client()
        client.enableNsLogLogging()
        try client.setLogLevel(level: "trace")
        let connection = try client.createConnection()
        let privateKey = try client.createPrivateKey()
        try connection.setPrivateKey(key: privateKey)
        try connection.setProductId(id: "pr-fatqcwj9")
        try connection.setDeviceId(id: "de-ijrdq47i")
        try connection.setServerKey(key: "sk-9c826d2ebb4343a789b280fe22b98305")
        try connection.setServerConnectToken(sct: "WzwjoTabnvux")
        try connection.connect()
        let details: NabtoEdgeClient.DeviceDetails = try NabtoEdgeClient.IamUtil.getDeviceDetails(connection: connection)
        DispatchQueue.main.async {
            self.spinner.stopAnimating()
            self.label.text = "Device SDK Version: \(details.NabtoVersion)"
        }
    }