Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Microsoft Auth provider for a smooth auth experience #68

Closed
TylerLeonhardt opened this issue Mar 7, 2022 · 0 comments · Fixed by #78
Closed

Use the Microsoft Auth provider for a smooth auth experience #68

TylerLeonhardt opened this issue Mar 7, 2022 · 0 comments · Fixed by #78
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@TylerLeonhardt
Copy link

Hi 👋 I work on the VS Code team. I'd like to let you know about a discovery we made around auth and how to use the built-in Microsoft auth with Azure DevOps APIs.

First off, if you aren't familiar with the auth APIs in VS Code, check out our API.

With that said, if you wanted to get an access token to interact with Azure DevOps, all you have to do is:

const session = await vscode.authentication.getSession(
  // Specifies the Microsoft Auth Provider
  'microsoft',
  // This GUID is the Azure DevOps GUID and you basically ask for a token that can be used to interact with AzDO. This is publicly documented all over
  ['499b84ac-1321-427f-aa17-267ca6975798/.default', 'offline_access'],
  {
    // be sure to take a look at the other options
    createIfNone: true;
  });

At this point, session.accessToken is an access token that can be used to query AzDO APIs.

No more PAT creation for the user!

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants