Skip to content

Commit ecfd8ae

Browse files
Merge pull request #279313 from NReppekus/nataliehein/restAAD
Describe aad auth for short audio rest api
2 parents b1f3ea4 + 03b8d5d commit ecfd8ae

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

articles/ai-services/speech-service/includes/cognitive-services-speech-service-rest-auth.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ Each request requires an authorization header. This table illustrates which head
1313
| `Ocp-Apim-Subscription-Key` | Yes | Yes |
1414
| `Authorization: Bearer` | Yes | Yes |
1515

16-
When you're using the `Ocp-Apim-Subscription-Key` header, you're only required to provide your resource key. For example:
16+
When you're using the `Ocp-Apim-Subscription-Key` header, only your resource key must be provided. For example:
1717

1818
```http
1919
'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
2020
```
2121

22-
When you're using the `Authorization: Bearer` header, you're required to make a request to the `issueToken` endpoint. In this request, you exchange your resource key for an access token that's valid for 10 minutes.
22+
When you're using the `Authorization: Bearer` header, you need to make a request to the `issueToken` endpoint. In this request, you exchange your resource key for an access token that's valid for 10 minutes.
23+
24+
Another option is to use Microsoft Entra authentication that also uses the `Authorization: Bearer` header, but with a token issued via Microsoft Entra ID. See [Use Microsoft Entra authentication](#use-microsoft-entra-authentication).
2325

2426
### How to get an access token
2527

@@ -154,3 +156,42 @@ Connection: Keep-Alive
154156
155157
// Message body here...
156158
```
159+
160+
### Use Microsoft Entra authentication
161+
162+
To use Microsoft Entra authentication with the Speech to text REST API for short audio, you need to create an access token.
163+
The steps to obtain the access token consisting of Resource ID and Microsoft Entra access token are the same as when using the Speech SDK.
164+
Follow the steps here [Use Microsoft Entra authentication](../how-to-configure-azure-ad-auth.md)
165+
166+
> [!div class="checklist"]
167+
>
168+
> - Create a Speech resource
169+
> - Configure the Speech resource for Microsoft Entra authentication
170+
> - Get a Microsoft Entra access token
171+
> - Get the Speech resource ID
172+
173+
After the resource ID and the Microsoft Entra access token were obtained, the actual access token can be constructed following this format:
174+
```http
175+
"aad#YOUR_RESOURCE_ID#YOUR_MICROSOFT_ENTRA_ACCESS_TOKEN";
176+
```
177+
You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and the access token.
178+
179+
Here's a sample HTTP request to the Speech to text REST API for short audio:
180+
181+
```http
182+
POST /cognitiveservices/v1 HTTP/1.1
183+
Authorization: Bearer YOUR_ACCESS_TOKEN
184+
Host: westus.stt.speech.microsoft.com
185+
Content-type: application/ssml+xml
186+
Content-Length: 199
187+
Connection: Keep-Alive
188+
189+
// Message body here...
190+
```
191+
192+
To learn more about Microsoft Entra access tokens, including token lifetime, visit [Access tokens in the Microsoft identity platform](/azure/active-directory/develop/access-tokens).
193+
194+
195+
196+
197+

0 commit comments

Comments
 (0)