Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Get cookies from external website after authentication

$
0
0

Hi All,

I have been a C++ developer all my life. So i am new to asp.net and web technologies as such. 

I need to develop a small cross-platform application, which will basically open an external website. And allow the user to sign-in (username and password). Once the user is authenticated, this application needs to fetch the cookies and hand it over to a C++ desktop application. It is basically SSO credentials, so the website redirects to a page where the authentication happens.

For this, i have written some code, which for now opens the website. But i am cluless on how to get the cookies and hand it over to the C++ app.

//Program.cs 

class Program { static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseStartup<Startup>() .Build(); host.Start(); OpenBrowser("https://mywebsite.com/auth/samlsso.php"); } public static void OpenBrowser(string url) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Process.Start(new ProcessStartInfo("cmd", $"/c start {url}")); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Process.Start("xdg-open", url); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Process.Start("open", url); } else { // throw } } }

 //startup.cs

namespace SampleCore
{
    public class Startup
    {
        public void Configure(IApplicationBuilder builder)
        {
            builder.Run(appContext =>
            {
                return appContext.Response.WriteAsync("Hey, I'm from Web!");
            });
        }
    }
}


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>