From bb86bffaff263beea12343251cc7142fd2b2a4d4 Mon Sep 17 00:00:00 2001 From: Craig Treasure Date: Thu, 4 Feb 2021 18:14:18 -0800 Subject: [PATCH] Added a client consuption example - In the board review, they requested that we add an example of how someone would consume the AccessToken in a client. --- .../README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sdk/mixedreality/Azure.MixedReality.Authentication/README.md b/sdk/mixedreality/Azure.MixedReality.Authentication/README.md index 83158cce19ee..a26eeee3f20f 100644 --- a/sdk/mixedreality/Azure.MixedReality.Authentication/README.md +++ b/sdk/mixedreality/Azure.MixedReality.Authentication/README.md @@ -22,6 +22,7 @@ token from the STS that can be used to access Mixed Reality services. - [MixedRealityStsClient](#mixedrealitystsclient) - [Examples](#examples) - [Retrieve an access token](#retrieve-an-access-token) + - [Using the access token in a Mixed Reality client library](#using-the-access-token-in-a-mixed-reality-client-library) - [Troubleshooting](#troubleshooting) - [Next steps](#next-steps) - [Client libraries supporting authentication with Mixed Reality Authentication](#client-libraries-supporting-authentication-with-mixed-reality-authentication) @@ -159,6 +160,24 @@ AccessToken token = await client.GetTokenAsync(accountId); See the authentication examples [above](#authenticate-the-client) for more complex authentication scenarios. +#### Using the access token in a Mixed Reality client library + +Some Mixed Reality client libraries might accept an access token in place of a credential. For example: + +```csharp +// GetMixedRealityAccessTokenFromWebService is a hypothetical method that retrieves +// a Mixed Reality access token from a web service. The web service would use the +// MixedRealityStsClient and credentials to obtain an access token to be returned +// to the client. +AccessToken accessToken = await GetMixedRealityAccessTokenFromWebService(); + +SpatialAnchorsAccount account = new SpatialAnchorsAccount(accountId, accountDomain); +SpatialAnchorsClient client = new SpatialAnchorsClient(account, accessToken); +``` + +Note: The `SpatialAnchorsClient` usage above is hypothetical and may not reflect the actual library. Consult the +documentation for the client library you're using to determine if and how this might be supported. + ## Troubleshooting - See [Error Handling](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/identity/Azure.Identity/README.md#error-handling) for Azure.Identity.