nabto_client_connection_set_server_jwt_token()

DESCRIPTION

Set a JWT token to use when connecting to the server.

If the authentication method for the server_key is set to JWT in the solution configuration set in the Nabto Cloud Console, this option is required. If the user is authenticated and can get a JWT this JWT can be given to the connect such that the relay server can validate that the given user has access to connect to the specific device.

The server will look for a claim with a list of ids granted access to based on the token. product_id.device_id

The server is configured with an audience, issuer, nabto_ids_claim and a jwks_uri. The server validates the client requests against these parameters. These parameters is customizable for each server_key.

example token payload content:

{
"aud": "...",
"iss": "...",
"exp": "...",
"nabto_ids": "pr-12345678.de-12345678 pr-87654321.de-87654321"
}

DECLARATION

NABTO_CLIENT_DECL_PREFIX NabtoClientError NABTO_CLIENT_API
nabto_client_connection_set_server_jwt_token(NabtoClientConnection* connection,
                                             const char* jwt)

PARAMETERS

connection:
[in] The connection
jwt:
[in] The base64 JWT string, the string is copied into the connection.

RETURNS

  • NABTO_CLIENT_EC_OK: on success
  • NABTO_CLIENT_EC_INVALID_STATE: if the connection is not in the setup phase