Login to wordpress using another sites authentication.

What you’re after is called Single Sign On or SSO. You would essentially be bypassing WordPress’ authentication methods and use those from a 3rd party. WordPress needs a local user of some kind for normal operations to work (the user_can() function for example.)

So the general gist would be something like this
– Send any request for authentication to a 3rd party who will yay or nay and return some data about the user
– if yay, check if there is a WordPress user that represents the authenticated user. If not, create one and add any meta data you might need from the third party.
– these WordPress users are like placeholders and every time you successfully authenticate, you update the meta data of the WordPress user to keep things in sync.

This is how OneLogin does it and you can poke around their WordPress plugin to get a sense of how it works. https://wordpress.org/plugins/onelogin-saml-sso/