Skip to content

Commit

Permalink
Merge pull request #6755 from microsoft/fix/ts-samples
Browse files Browse the repository at this point in the history
fix/ts samples
  • Loading branch information
baywet authored Nov 11, 2024
2 parents 16dd685 + d96510d commit 16f5455
Show file tree
Hide file tree
Showing 238 changed files with 1,294 additions and 20,431 deletions.
24 changes: 14 additions & 10 deletions get-started/azure-auth/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@
// Licensed under the MIT License.

// <ProgramSnippet>
import { DeviceCodeCredential } from '@azure/identity';
import { AzureIdentityAuthenticationProvider } from '@microsoft/kiota-authentication-azure';
import { FetchRequestAdapter } from '@microsoft/kiota-http-fetchlibrary';
import { createGetUserApiClient } from './client/getUserApiClient';
import { DeviceCodeCredential } from "@azure/identity";
import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure";
import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
import { createGetUserApiClient } from "./client/getUserApiClient.js";

const clientId = 'YOUR_CLIENT_ID';
const clientId = "YOUR_CLIENT_ID";

// The auth provider will only authorize requests to
// the allowed hosts, in this case Microsoft Graph
const allowedHosts = new Set<string>([ 'graph.microsoft.com' ]);
const graphScopes = [ 'User.Read' ];
const allowedHosts = new Set<string>(["graph.microsoft.com"]);
const graphScopes = ["User.Read"];

const credential = new DeviceCodeCredential({
clientId: clientId,
userPromptCallback: (deviceCodeInfo) => {
console.log(deviceCodeInfo.message);
}
},
});

const authProvider =
new AzureIdentityAuthenticationProvider(credential, graphScopes, undefined, allowedHosts);
const authProvider = new AzureIdentityAuthenticationProvider(
credential,
graphScopes,
undefined,
allowedHosts
);
const adapter = new FetchRequestAdapter(authProvider);

const client = createGetUserApiClient(adapter);
Expand Down
Loading

0 comments on commit 16f5455

Please sign in to comment.