forked from hahahumble/speechgpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b5d908
commit 6a236c3
Showing
2 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import axios from 'axios'; | ||
|
||
export async function getAzureToken(subscriptionKey: string, region: string): Promise<string> { | ||
const url = `https://${region}.api.cognitive.microsoft.com/sts/v1.0/issueToken`; | ||
|
||
try { | ||
const response = await axios.post(url, null, { | ||
headers: { | ||
'Ocp-Apim-Subscription-Key': subscriptionKey, | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
}, | ||
}); | ||
|
||
return response.data; | ||
} catch (error) { | ||
throw new Error(`Error getting token: ${error}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters