Skip to content

Conversation

@Mister-Joe
Copy link

Overview

The Get-GraphTokens function currently only supports device code flow for authentication. This can be problematic when an Entra ID tenant has blocked device code flow via a conditional access policy. This PR adds support for authorization code flow, allowing users to choose between device code flow (default) or authorization code flow (Get-GraphTokens -AuthorizationCodeFlow).

How does it work?

A browser is opened and a request is made to the /organizations/oauth2/v2.0/authorize endpoint. The user is prompted to authenticate. If authentication is successful, the browser is redirected to an HttpListener on localhost where the authorization code is captured.

This authorization code is then exchanged in a request to the /organizations/oauth2/v2.0/token endpoint for an access token and FOCI refresh token for the Azure CLI client, which in turn is exchanged in another request to the /organizations/oauth2/v2.0/token endpoint for an access token and refresh token for the Microsoft Office client.

Usage

  1. Get-GraphTokens -AuthorizationCodeFlow
image
  1. In the browser window that opens, select your account and authenticate.
image image
  1. Return to your CLI and note that you now have tokens for the correct resource, client, and scopes.
image

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant