Oauth 2.0 Azure in console program

1

I need to get authorization, token and refresh token from a console application. I need the logarme screen to appear in the console application. I know it's possible but I'm not capable

   string url = $"https://login.microsoftonline.com/common/oauth2/authorize?client_id={*clientID*}&response_type=code";
    WebRequest request = WebRequest.Create(url);

    WebResponse response = request.GetResponse();

Can you help me?

    
asked by eromerof 05.09.2018 в 15:41
source

1 answer

1

You're dealing with it the wrong way, so it will not work for you.

What you should do in summary is:

  • Register your app in the Azure active directory
  • Use the secrets of the App to start the authentication flow
  • when that is ready you can take several approximations one of them \
  • generate a URL for authentication, which the user or your app can do to launch the browser
  • once in the browser the user receives a verification code
  • the user enters the code in the console, you must use your program to receive that code
  • with that code you end the flow of authentication
  • It is not so trivial to do but it is not so complex either, but if it is the first time that you face this issue it can be quite cumbersome.

    More info here even though it is with the first version of Azure Active Directory, but the flow is still basically the same even if the interface has changed.

    link

    I also recommend using ADAL .

        
    answered by 03.10.2018 в 19:06