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
Copy file name to clipboardExpand all lines: articles/azure-signalr/signalr-concept-client-negotiation.md
+43-1Lines changed: 43 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,7 +218,11 @@ Then your clients can request the function endpoint `https://<Your Function App
218
218
219
219
### Self-exposing `/negotiate` endpoint
220
220
221
-
You could also expose the negotiation endpoint in your own server and return the negotiation response by yourself if you are using other languages. Below is a pseudo code in JavaScript showing how to implement the negotiation endpoint for hub `chat`.
221
+
You could also expose the negotiation endpoint in your own server and return the negotiation response by yourself if you are using other languages.
222
+
223
+
#### Using ConnectionString
224
+
225
+
Below is a pseudo code in JavaScript showing how to implement the negotiation endpoint for hub `chat` and generate access token from Azure SignalR connection string.
222
226
223
227
```js
224
228
importexpressfrom'express';
@@ -242,6 +246,44 @@ let connection = new signalR.HubConnectionBuilder().withUrl('/chat').build();
242
246
connection.start();
243
247
```
244
248
249
+
#### Using Microsoft Entra ID
250
+
Azure SignalR also provides REST API `POST /api/hubs/${hub}/:generateToken?api-version=2022-11-01&userId=${userId}&minutesToExpire=${minutesToExpire}` to generate the client access token for you when you are using Microsoft Entra ID.
251
+
252
+
The steps are:
253
+
1. Follow [Add role assignments](signalr-howto-authorize-application.md#add-role-assignments-in-the-azure-portal) to assign role `SignalR REST API Owner` or `SignalR Service Owner` to your identity so that your identity has the permission to invoke the REST API to generate the client access token.
254
+
2. Use Azure Identity client library to fetch the Microsoft Entra ID token with scope `https://signalr.azure.com/.default`
255
+
3. Use this token to visit the generate token REST API
256
+
4. Return the client access token in the negotiation response.
257
+
258
+
Below is a pseudo code in JavaScript showing how to implement the negotiation endpoint for hub `chat` and get access token using Microsoft Entra ID and REST API `/generateToken`.
0 commit comments