Skip to content

Getting started instructions are missing auth provider setup #507

Description

Currently, getting started instructions are missing the steps to configure the auth provider. We're referencing our live documentation, which unfortunately isn't working, because it's incompatible with this SDK. To help developers try this SDK, we should include a fully working sample, for example:

import { ClientSecretCredential } from '@azure/identity';
import { AzureIdentityAuthenticationProvider } from '@microsoft/kiota-authentication-azure';
import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
import { createGraphServiceClient } from "@microsoft/msgraph-sdk";
import "@microsoft/msgraph-sdk-users";
import 'dotenv/config';

(async () => {
  const credential = new ClientSecretCredential(
    process.env.TENANT_ID,
    process.env.CLIENT_ID,
    process.env.CLIENT_SECRET
  );
  const authProvider = new AzureIdentityAuthenticationProvider(credential, ['https://graph.microsoft.com/.default']);
  const requestAdapter = new FetchRequestAdapter(authProvider);
  const graphServiceClient = createGraphServiceClient(requestAdapter);

  try {
    const users = await graphServiceClient.users.get();
    console.log(JSON.stringify(users));
  }
  catch (error) {
    console.error(error);
  }
})();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions