Share this page

# mqtt_set_credentials

Sets the user name and password.

## C Language

int mqtt_set_credentials( MQTT handle, const char* username, const char* password);

MQTT Vuser Functions

## Arguments

Name | Comments
--- | ---
handle | The MQTT client handle returned by mqtt_create.
username | The account name used to log on to the broker during connection.
password | Password or MQTT_NONE.

## General Information

mqtt_set_credentials sets the user name and password of a broker server account. Call this function before mqtt_connect.

If invalid arguments are passed, the Vuser aborts, even if Continue on error is set.

## Return Values

MQTT_SUCCESS or MQTT_FAIL

## Parameterization

Standard parameterization is available for this function.

Exception: password cannot be parametrized (to avoid exposure in the output log).

## Example

`MQTT client = mqtt_create();`

// Set credentials for authentication, store password in encrypted form

`mqtt_set_credentials(client, "sensor1", lr_unmask("582c4eee24119befgffb"));`

`mqtt_connect(client, "tcp://test.broker.com:1883");`

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: