Adding Identity breaks Authentication using OAuth
Describe the bug
When IServiceCollection.AddAuthentication().AddFacebook() is used, the user is populated with Facebook details after a Challenge sequence. When IServiceCollection.AddIdentity() is put in the mix, this breaks OAuth completely.
To Reproduce
Steps to reproduce the behavior:
- ASP.NET Core 2.1 or greater
- Minimal example
Expected behavior
When services.AddIdentity is omitted, the JSON output for route / is predictably the following:
{"isAuthenticated":true,"name":Jesse Hallam,"authenticationType":"Facebook"}
Unexpected behavior
When services.AddIdentity is put back in the mix, this "breaks" the OAuth flow in some undocumented way, and the JSON output is becomes:
{"isAuthenticated":false,"name":null,"authenticationType":null}
When Identity is in, a (Facebook) OAuth flow results in an Identity.External cookie being sent. Is there something specific that should be done to get the external user out of the cookie?
Perhaps SignInManager<TUser>.GetExternalLoginInfoAsync() is a candidate for extracting the External cookie, but it returns null.
Without seeing a minimal example of what you're doing here, or indeed what you're expecting its rather hard to help.
But identity is meant to be (nearly) the sole source of truth in an app. Facebook users would have to register a local account into identity in the default scenarios, and then the login flow would go through identity again to map to the local user, rather than have external auth providers.
We're closing this issue as no response or updates have been provided in a timely manner. If you have more details and are encountering this issue please add a new reply and re-open the issue.