Discourse SSO synced login with API

I’m having trouble in syncing login on discourse via api, I have go through many posts but didn’t get it.

As mentioned in the following post https://meta.discourse.org/t/sso-synced-login-state-tips/60464 we can append the session/sso with forum site url and it will logged into discourse when user click on it.

But what we need is to login user on discourse from server side so we don’t have to change any link to set user logged in.
As a reference i can mention newrelic implementation. When user logged in to main site and refresh forum site without clicking any link, it will be set as logged in.
https://discuss.newrelic.com/

Can you please suggest how we can achieve this?
Thanks