Skip to content

Commit d00f043

Browse files
committed
Edits to Entra Java
1 parent 39fdf5e commit d00f043

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

includes/iot-hub-howto-connect-service-iothub-entra-java.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ ms.date: 11/06/2024
1313

1414
A backend app that uses Microsoft Entra must successfully authenticate and obtain a security token credential before connecting to IoT Hub. This token is passed to a IoT Hub connection method. For general information about setting up and using Microsoft Entra for IoT Hub, see [Control access to IoT Hub by using Microsoft Entra ID](/azure/iot-hub/authenticate-authorize-azure-ad).
1515

16-
For an overview of Java SDK authentication, see [Getting started with user authentication on Azure](https://learn.microsoft.com/en-us/azure/developer/java/sdk/authentication/azure-hosted-apps).
16+
For an overview of Java SDK authentication, see [Getting started with user authentication on Azure](/azure/developer/java/sdk/authentication/azure-hosted-apps).
17+
18+
For simplicity, this section focuses on describing authentication using client secret.
1719

1820
##### Configure Microsoft Entra app
1921

@@ -29,13 +31,13 @@ For more information about setting up a Microsoft Entra app, see [Quickstart: Re
2931

3032
##### Authenticate using DefaultAzureCredential
3133

32-
The easiest way to use Microsoft Entra to authenticate a backend application is to use [DefaultAzureCredential](/azure/developer/java/sdk/authentication/credential-chains#defaultazurecredential-overview), but it's recommended to use a different method in a production environment including a specific `TokenCredential` or pared-down `ChainedTokenCredential`. For simplicity, this section describes authentication using `DefaultAzureCredential` and Client secret.
34+
The easiest way to use Microsoft Entra to authenticate a backend application is to use [DefaultAzureCredential](/azure/developer/java/sdk/authentication/credential-chains#defaultazurecredential-overview), but it's recommended to use a different method in a production environment including a specific `TokenCredential` or pared-down `ChainedTokenCredential`.
3335
For more information about the pros and cons of using `DefaultAzureCredential`, see
34-
[ChainedTokenCredential](/java/sdk/authentication/credential-chains).
36+
[ChainedTokenCredential](/azure/developer/java/sdk/authentication/credential-chains).
3537

3638
[DefaultAzureCredential](/java/api/com.azure.identity.defaultazurecredential) supports different authentication mechanisms and determines the appropriate credential type based on the environment it's executing in. It attempts to use multiple credential types in an order until it finds a working credential.
3739

38-
You can authenticate Microsoft Entra app credentials using [DefaultAzureCredentialBuilder](/java/api/com.azure.identity.defaultazurecredentialbuilder). Save connection parameters such as client secret tenantID, clientID, and client secret values as environmental varaibles. Once the `TokenCredential` is created, pass it to [ServiceClient](https://learn.microsoft.com/en-us/java/api/com.azure.core.annotation.serviceclient) or other builder as the 'credential' parameter.
40+
You can authenticate Microsoft Entra app credentials using [DefaultAzureCredentialBuilder](/java/api/com.azure.identity.defaultazurecredentialbuilder). Save connection parameters such as client secret tenantID, clientID, and client secret values as environmental varaibles. Once the `TokenCredential` is created, pass it to [ServiceClient](/java/api/com.azure.core.annotation.serviceclient) or other builder as the 'credential' parameter.
3941

4042
In this example, `DefaultAzureCredentialBuilder` will attempt to authenticate a connection from the list described in [DefaultAzureCredential](/java/api/com.azure.identity.defaultazurecredential). The result of a successful Microsoft Entra authentication is a security token credential that is passed to a constructor.
4143

@@ -45,7 +47,7 @@ TokenCredential defaultAzureCredential = new DefaultAzureCredentialBuilder().bui
4547

4648
##### Authenticate using ClientSecretCredentialBuilder
4749

48-
You can use [ClientSecretCredentialBuilder](/java/api/com.azure.identity.clientsecretcredentialbuilder) to create a credential using client secret information. If successful, this method returns a [TokenCredential](/java/api/com.azure.core.credential.tokencredential).
50+
You can use [ClientSecretCredentialBuilder](/java/api/com.azure.identity.clientsecretcredentialbuilder) to create a credential using client secret information. If successful, this method returns a [TokenCredential](/java/api/com.azure.core.credential.tokencredential) that can be passed to [ServiceClient](/java/api/com.azure.core.annotation.serviceclient) or other builder as the 'credential' parameter.
4951

5052
In this example, Microsoft Entra app registration client secret, client ID, and tenant ID values have been added to environment variables. These environment variables are used by `ClientSecretCredentialBuilder` to build the credential.
5153

@@ -62,10 +64,23 @@ TokenCredential credential =
6264
.build();
6365
```
6466

65-
##### Authenticate using InteractiveBrowserCredential
67+
##### Other authentication classes
68+
69+
The Java SDK also includes these classes that authenticate a backend app with Microsoft Entra:
6670

67-
Use [InteractiveBrowserCredential](https://learn.microsoft.com/en-us/java/api/com.azure.identity.interactivebrowsercredential) to authenticate a user sign-in using a web browser.
71+
* [AuthorizationCodeCredential](/java/api/com.azure.identity.authorizationcodecredential)
72+
* [AzureCliCredential](/java/api/com.azure.identity.azureclicredential)
73+
* [AzureDeveloperCliCredential](/java/api/com.azure.identity.azuredeveloperclicredential)
74+
* [AzurePipelinesCredential](/java/api/com.azure.identity.azurepipelinescredential)
75+
* [ChainedTokenCredential](/java/api/com.azure.identity.chainedtokencredential)
76+
* [ClientAssertionCredential](/java/api/com.azure.identity.clientassertioncredential)
77+
* [ClientCertificateCredential](/java/api/com.azure.identity.clientcertificatecredential)
78+
* [DeviceCodeCredential](/java/api/com.azure.identity.devicecodecredential)
79+
* [EnvironmentCredential](/java/api/com.azure.identity.environmentcredential)
80+
* [InteractiveBrowserCredential](/java/api/com.azure.identity.interactivebrowsercredential)
81+
* [ManagedIdentityCredential](/java/api/com.azure.identity.managedidentitycredential)
82+
* [OnBehalfOfCredential](/java/api/com.azure.identity.onbehalfofcredential)
6883

6984
##### Code samples
7085

71-
For working samples of Microsoft Entra service authentication, see [Role based authentication sample](github.com/Azure/azure-iot-service-sdk-java/tree/main/service/iot-service-samples/role-based-authorization-sample).
86+
For working samples of Microsoft Entra service authentication, see [Role based authentication sample](https://github.com/Azure/azure-iot-service-sdk-java/tree/main/service/iot-service-samples/role-based-authorization-sample).

0 commit comments

Comments
 (0)