Based on your description, you'll likely want to leverage OAuth2.0. For PHP-specific code and detailed steps, there is no ready-made API endpoint for the auto-login feature that you are asking for, as this needs to be achieved with a combination of your app's logic and OAuth2.0 flow.
Although the community cannot write custom code for you, they can help troubleshoot what you've already created. You are welcome to share a code block or example of what you've come up with or where you are stuck.