Responds to redirected user. OAuth2 protocol

0

In the OAuth2 protocol, once the user has granted permission to an application (Windows Forms) and is redirected to the url link , how can you get the code SERVER_GENERATED_AUTHORIZATION_CODE in a development made in c #?

The operation of the application would be explained in link

The CallInitialUri method makes a call to the URIBTDevelopers url. After the call, a login screen is received, which is displayed on webBrowser1; From the browser, the user logs in and is asked to grant permissions to my application.

If the user grants the necessary permissions, the application must receive the code in the url: link . It is at this point where I have doubts ... How do you "listen" to that url after the user grants the necessary permissions?

public async Task CallInitialUri ( )
{
    String              strUriApp;                  // Cadena Uri de la aplicación.
    String              strUriBTDevelopers;     // Cadena Uri de autorización.
    String              strClientId;                // ClientId;
    HttpClient          pClient;                        // Cliente HTTP.

    try
    {
        /* Se inicializan las variablas necesarias */
        strClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        strUriApp = "https://miaplicacion.com/";
        pClient = new HttpClient();
        pClient.DefaultRequestHeaders.Clear();
        pClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        /* Se crea la cadena Uri */
        strUriBTDevelopers = "https://developers.bantotal.com/auth/dialog/authorize?client_id=" + strClientId +"&response_type=code&redirect_uri=" + strUriApp;

        /* Se navega al Uri de forma asíncrona */
        Task<String> stringTask = pClient.GetStringAsync(strUriBTDevelopers);

        /* Se muestra la web en el navegador de la aplicación */
        webBrowser1.DocumentText = await stringTask;
    }
    catch ( Exception Ex )
    {
        MessageBox.Show(Ex.ToString());
    }
}
    
asked by Sergio 07.08.2017 в 13:33
source

1 answer

0

at the end of the authentication, call the url that you passed when it finishes, at that moment, send by parameters the SERVER_GENERATED_AUTHORIZATION_CODE in the request parameters of the call that you make at the end.

If you can indicate some code on the page link , how do you pick up this call, what this url ...

    
answered by 07.08.2017 в 14:12