'Console app - recreate Azure CLI's `az --login`'s web browse localhost callback authenitcation technique

When using Azure CLI - and other tools like Azure Functions extension for VS Code - the user logs into Azure using the localhost callback technique and the whole Azure world opens up.

The Azure CLI flow is:

  • az --login
  • login in a browser (including 2 factor auth)
  • Do amazing things
    • with any Azure resource that your account has access too
      • across multiple subscriptions and resource groups.

Is there a package that allows to do this in a console app (C#)?



Solution 1:[1]

I think you're looking for Microsoft identity platform and the OAuth 2.0 device authorization grant flow.

The Microsoft identity platform supports the device authorization grant, which allows users to sign in to input-constrained devices such as a smart TV, IoT device, or printer. To enable this flow, the device has the user visit a webpage in their browser on another device to sign in. Once the user signs in, the device is able to get access tokens and refresh tokens as needed.

Device Code Flow

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rickvdbosch