A possible way to check if the user is federated or not could be via:
POST
https://login.microsoftonline.com/GetUserRealm.srf
Content-Type: application/x-www-form-urlencoded
Accept: application/json
handler=1&login=johndoe@somecompany.onmicrosoft.com