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());
}
}