function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Larry Davis 8Larry Davis 8 

how does a connected app validate an existing user session using single sign on ?

I have a web app that requires authentication. ?| I would like to link it to salesforce to provide a single sign on. ?| My use case is this :

- User logs into salesforce
- User clicks on a link for a connected app and then goes to my web app page
- Because the user is already logged in, the user should not have to log in again

So a single sign on solution with oauth seems like a good solution. ?| However, all the discussions I see are from the perspective of the user starting on my app page and then redirecting to salesforce to do the auth. ?| I want to start on my 
salesforce app launcher page (with authentication as needed) and then go to the app page.

When the user gets to my app page, I do not know if they have a session and I need a way to check if they have a session through a query to salesforce. ?| I know I can do this by going through the oauth flow but I would rather not redirect the
m to salesforce just to have the site redirect the user back as this would be a bad user experience. ?| I believe I can use a hidden iframe to do this cycle but this seems like a lot of work that could be avoided if the original link from sale
sforce to my app page just included the user's current session token (or any token that can be linked to the user's current session)

With the app launcher and the connected apps, I assume that this cannot be unique problem so can someone point me in the right direction on how to get this working. ?| Is there some way to configure the connected app to include session informa
tion as part of the link or is there another recommended way of sharing the session FROM salesforce to the connected app ?
Niran NSNiran NS
Hi Larry

You could use the login history to track the user logins to salesforce if you are using salesforce as the Identity provider.

So a user who wishes to access the webpage
1. Login to Salesforce  (Login History captures it).
2. Authenticates the user
3. Redirects the user to WebPage.

I believe you will not have to query to check for valid sessions through code.
 
Niran NSNiran NS
The below link could help you.

https://developer.salesforce.com/docs/atlas.en-us.identityImplGuide.meta/identityImplGuide/identity_how_to.htm