{"id":8008,"date":"2021-04-07T19:18:38","date_gmt":"2021-04-07T19:18:38","guid":{"rendered":"https:\/\/blogs.aaddevsup.xyz\/?p=8008"},"modified":"2021-04-08T15:18:44","modified_gmt":"2021-04-08T15:18:44","slug":"using-msal-in-a-vb-net-winforms-application","status":"publish","type":"post","link":"https:\/\/blogs.aaddevsup.xyz\/2021\/04\/using-msal-in-a-vb-net-winforms-application\/","title":{"rendered":"Using MSAL in a VB.Net Winforms application"},"content":{"rendered":"\n
All of our MSAL samples are for either Web, mobile client or console applications in c#. This blog post will show how you can also use MSAL in vb.net in a Winforms desktop application.<\/p>\n\n\n\n
When creating a winforms application, the thing to remember is that code in your form will run under the UI thread, which, for the most part is ok. However, when MSAL prompts for credentials, it will get thread-locked by the UI or visa versa if you just run that under the UI thread. You must make the authentication and token requests on a separate thread. In this sample, I show you one way you can handle that complex issue with a task and a delegate method and retrieve the tokens from the call. <\/p>\n\n\n\n
This sample project can be found on my gitHub here<\/a>. You will need to create an app registration in your tenant for this project and then update the Form1.vb variables with the client_id, client_secret and tenant_id. Please refer to the readme file in the gitHub for specifics about the reply URI.<\/p>\n\n\n\n The sample will demonstrate how to: <\/p>\n\n\n\n