[SalesForce] How to login to SSO enabled Org using API in .net application

I have created one .net desktop application to fetch some data and metadata from Salesforce. So, this application first ask for the salesforce username and password to login and once log-in is successful, it will fetch some data from the org (using Salesforce API).

Now, my customer has implemented SSO with Active Directory in his salesforce Org and he also want to implement same in .net application.
So, I want to implement SSO in .net application so that user does not need to remember credentials and can be authenticated by Windows Login.
Anyone have idea how I can implement this in .net Application? Any example available for implementing SSO in .net desktop application?

Best Answer

Use OpenID Connect or SAML. OpenID Connect (OIDC) was specifically designed for this use case but support for it in libraries/frameworks is still evolving. You'll need ASP.NET Core 1.0 (previously known as ASP.NET 5) on .NET side . With SAML, you'll have to use an embedded web browser control. While that isn't a very desktop-friendly approach, it is widely used and there are many examples out there.

OIDC
- Salesforce side: https://help.salesforce.com/articleView?id=sso_provider_openid_connect.htm&language=en_US&type=0
- .NET side: here's a good blog https://andrewlock.net/an-introduction-to-openid-connect-in-asp-net-core/

SAML:
- Salesforce side: https://help.salesforce.com/articleView?id=sso_saml.htm&type=0
- .NET side: Look at Kentor AuthServices middleware

Related Topic