Search in sources :

Example 6 with TokenCredential

use of com.azure.core.credential.TokenCredential in project azure-iot-sdk-java by Azure.

the class RoleBasedAuthenticationSample method main.

public static void main(String[] args) {
    SamplesArguments parsedArguments = new SamplesArguments(args);
    // Credentials can be built from types from the Azure Identity library like ClientSecretCredential.
    // The Azure Identity library also defines other implementations of the TokenCredential interface such as
    // DefaultAzureCredential, InteractiveBrowserCredential, and many others.
    TokenCredential credential = new ClientSecretCredentialBuilder().tenantId(parsedArguments.getTenantId()).clientId(parsedArguments.getClientId()).clientSecret(parsedArguments.getClientSecret()).build();
    // "my-azure-iot-hub.azure-devices.net" for example
    String iotHubHostName = parsedArguments.getIotHubHostName();
    String newDeviceId = runRegistryManagerSample(iotHubHostName, credential);
    runTwinClientSample(iotHubHostName, credential, newDeviceId);
    runServiceClientSample(iotHubHostName, credential, newDeviceId);
    runJobClientSample(iotHubHostName, credential);
    runDeviceMethodClientSample(iotHubHostName, credential, newDeviceId);
}
Also used : ClientSecretCredentialBuilder(com.azure.identity.ClientSecretCredentialBuilder) TokenCredential(com.azure.core.credential.TokenCredential)

Aggregations

TokenCredential (com.azure.core.credential.TokenCredential)6 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)4 ClientSecretCredentialBuilder (com.azure.identity.ClientSecretCredentialBuilder)1 BlobServiceClientBuilder (com.azure.storage.blob.BlobServiceClientBuilder)1 StorageSharedKeyCredential (com.azure.storage.common.StorageSharedKeyCredential)1 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)1 DeviceMethodClientOptions (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceMethodClientOptions)1 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)1 DeviceTwinClientOptions (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinClientOptions)1 DigitalTwinClient (com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClient)1 DigitalTwinClientOptions (com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClientOptions)1