You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GetClientAccessTokenOptions option = new GetClientAccessTokenOptions();
@@ -225,3 +244,71 @@ The same Client Access URL can be generated by using the Web PubSub server SDK.
225
244
---
226
245
227
246
In real-world code, we usually have a server side to host the logic generating the Client Access URL. When a client request comes in, the server side can use the general authentication/authorization workflow to validate the client request. Only valid client requests can get the Client Access URL back.
247
+
248
+
## Generate from RESTAPI`:generateToken`
249
+
You could also use Microsoft Entra ID and generate the token by invoking [Generate Client Token RESTAPI](/rest/api/webpubsub/dataplane/web-pub-sub/generate-client-token).
250
+
251
+
> [!NOTE]
252
+
> Web PubSub does not recommend that you create Microsoft Entra ID tokens for Microsoft Entra ID service principals manually. This is because each Microsoft Entra ID token is short-lived, typically expiring within one hour. Afterthis time, you must manually generate a replacement Microsoft Entra IDtoken. Instead, use [our SDKs](#generate-from-service-sdk) that automatically generate and replace expired Microsoft Entra ID tokens for you.
253
+
254
+
1. Follow [Authorize from application ](./howto-authorize-from-application.md#add-a-client-secret) to enable Microsoft Entra ID and add a client secret.
255
+
256
+
1. Gather the following information:
257
+
258
+
| Value name | How to get the value |
259
+
|---|---|
260
+
| TenantId | TenantId is the value of**Directory (tenant) ID** on the **Overview** pane of the application you registered. |
261
+
| ClientId | ClientId is the value of**Application (client) ID** from the **Overview** pane of the application you registered. |
262
+
| ClientSecret | ClientSecret is the value of the client secret you just added in step #1|
263
+
264
+
1. Get the Microsoft Entra ID token from Microsoft identity platform
265
+
266
+
We use [CURL](https://curl.se/) tool to show how to invoke the REST APIs. The tool is bundled into Windows 10/11, and you could install the tool following [Install CURL](https://curl.se/download.html).
267
+
268
+
```bash
269
+
# set neccessory values, replace the placeholders with your actual values
270
+
export TenantId=<your_tenant_id>
271
+
export ClientId=<your_client_id>
272
+
export ClientSecret=<your_client_secret>
273
+
274
+
curl -X POST "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token" \
The above curl command sends a POST request to Microsoft identity endpoint to get the [Microsoft Entra ID token](/entra/identity-platform/id-tokens) back.
283
+
In the response you see the Microsoft Entra ID token in`access_token`field. Copy and store it for later use.
284
+
285
+
1. Use the Microsoft Entra ID token to invoke `:generateToken`
286
+
287
+
```bash
288
+
# Replace the values in {} with your actual values.
0 commit comments