-
Notifications
You must be signed in to change notification settings - Fork 234
Open
Labels
Description
Hello,
I am trying to use the API with the access token i get back from MSAL, how should this be used with MSAL, are there scopes to be attached to the token, etc? It'll be nice if there's a sample with using MSAL access token.
Thank you:
export const getPipelines = async () => {
const { accessToken, userId } = await getAuthenticatedUser(); // msal token
let authBearerHandler = azdev.getBearerHandler(accessToken);
let connection = new azdev.WebApi(AdoConstants.OrgUrl, authBearerHandler); // <-----
const connectionData = await connection.connect();
console.log(`Hello ${connectionData.authenticatedUser?.providerDisplayName ?? "Unknown User"}`);
const pipelineApi: IPipelinesApi = await connection.getPipelinesApi();
const pipelines: Pipeline[] = await pipelineApi.listPipelines(AdoConstants.PROJECT_NAME);
console.log("Pipelines response: ", pipelines.length);
// ...
}