Description
Code365 is a free command tool that allows you to complete the first step in a Microsoft 365 authentication request for an application with redirection and code transfer. The program will use EDGE and allows you to retrieve the CODE and CODE VERIFIER, which are then used to request an ACCESS and REFRESH TOKEN pair. This program has been compiled only for Windows and allows you to use EDGE in normal or private mode.
Syntax
TenantID: -t e8a3d399-ki0d-4b85-9f26-xxxxxxxx <Mandatory>
ClientID: -c 2ji0d44d-a616-43bd-956b-xxxxxxxx <Mandatory>
Scope: -s 'mail.read mail.send offline_access' <Mandatory>
RedirectUrl: -r redirect_url <Mandatory>
Private mode: -p start EDGE in private mode <Optional>
Sample
In this example, we will are going to use an application that has a redirect to http://localhost. The application can read emails with GRAPH (mail.read delegate permission scoped by application access policy).

In this sample we are going to use EDGE in private mode.
The syntax is next:
CODE365.exe -t <tenant_id> -c <client_id> -s "mail.read" -r http://localhost -p

Code365 is going to wait and to open EDGE. If no session exists with M365 or no SSO exists, credential will be requested by M365:

The result is a URL that contains the code which is redirected to http://localhost. This URL does not work in this example but it is displayed in EDGE.

Copy the complete URL and then paste it into Code365. Then press ENTER. Code365 will generate the 2 fields that will allow you to proceed to the next step of M365 authentication: the CODE and the CODE VERIFIER.

You then have 10 minutes to request ACCESS TOKEN/REFRESH TOKEN from M365 using the CODE, the CODE VERIFIER, and the application authentication (CERTIFICATE or SECRET or none). You can use the Token365 tool available on this site to make these requests (with or without the Conditional Access Evaluation option).