Migration to Identity: Issues in the code snippets
This PR fixes two issues in the code snippets: - We passed the `tokenAudience` to the `ClientSecretCredential` as a parameter when `ClientSecretCredential` does not receive such parameter. - We were not calling the `getToken` method of the credential used in the sample for the `Regarding scopes` section. We were instead passing it to a credential. - In the `Regarding scopes` code snippet, we were also moving from `interactiveLogin` to `AzureCliCredential`, which is confusing. Using `InteractiveBrowserCredential` instead.
This commit is contained in:
Родитель
3710a14c26
Коммит
5eb43c1eb6
|
@ -127,7 +127,7 @@ const tokenAudience = "https://graph.microsoft.com/";
|
|||
|
||||
async function main() {
|
||||
- const credential = new ApplicationTokenCredentials(clientId, domain, secret, tokenAudience, environment);
|
||||
+ const credential = new ClientSecretCredential(tenantId, clientId, secret, tokenAudience, {
|
||||
+ const credential = new ClientSecretCredential(tenantId, clientId, secret, {
|
||||
+ authorityHost: AzureAuthorityHosts.AzureChina
|
||||
+ });
|
||||
const client = new SubscriptionClient(credential, {
|
||||
|
@ -221,7 +221,8 @@ async function main() {
|
|||
- const authResponse = await interactiveLogin({
|
||||
- tokenAudience: "https://vault.azure.net/"
|
||||
- });
|
||||
+ const credential = new AzureCliCredential("https://vault.azure.net/.default");
|
||||
+ const credential = new InteractiveBrowserCredential();
|
||||
+ const accessToken = await credential.getToken("https://vault.azure.net/.default");
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
|
Загрузка…
Ссылка в новой задаче