IamUtil.createUserAsync() Overload 1
DESCRIPTION
Asynchronously create an IAM user on device.
The specified AsyncIamResultReceiver closure is invoked with IamError.OK upon successful completion or with an error if an error occurs. See the createUser()
function for details about possible error codes.
DECLARATION
static public func createUserAsync(connection: Connection,
username: String,
password: String,
role: String,
closure: @escaping AsyncIamResultReceiver)
PARAMETERS
connection:
- An established connection to the device
username:
- Username for the new user
password:
- Password for the new user
role:
- IAM role for the new user
closure:
- Invoked when the user is created successfully or an error occurs
Overload 2
DESCRIPTION
Asynchronously create an IAM user on device.
Uses Swift concurrency and is therefore only available on iOS 13 and above.
DECLARATION
static public func createUserAsync(connection: Connection,
username: String,
password: String,
role: String
) async throws
PARAMETERS
connection:
- An established connection to the device
username:
- Username for the new user
password:
- Password for the new user
role:
- IAM role for the new user
THROWS ERRORS
INVALID_INPUT:
- if username is not valid as per https://docs.nabto.com/developer/api-reference/coap/iam/post-users.html#request
BLOCKED_BY_DEVICE_CONFIGURATION:
- if the device configuration does not allow the current user to create a new user (the
IAM:CreateUser
action is not allowed for the requesting role) ROLE_DOES_NOT_EXIST:
- the specified role does not exist in the device IAM configuration
IAM_NOT_SUPPORTED:
- if Nabto Edge IAM is not supported by the device