Skip to content

Using MSAL Access Token Disallowed #650

Description

@ghernandezmsft

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);

	// ...
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions