I'm developing an MVC web application (Asp.net C# - using AngularJS in the front). Currently, the users can log in to the site using username & password or oauth providers (such as google and Facebook).
We have developed a native mobile application that uses our asp.net web-api.
We want the users will be able to login using the same credentials to the mobile app and the website.
In order to do so, both projects (web-api & web application) are using the same DB with ASP.Net Identity. For example, if the user has created an account using username & password, he can log in on both platforms.
The problem is with external providers (Facebook, google...), when a user create an account on the web view the identity saves the users on the DB with a specific provider key (on the AspNetUserLogins table). And when the user login (or register) using the mobile app I only have the user token, and I don't know how to log the user in.
Then I've found this post: WebApi ASP.NET Identity Facebook login
which explains exactly what I've needed, only now I have 2 problems:
- Using the user token (from the mobile login) I retrieve his user ID and save it on the AspNetUserLogins table, but when using the web application it saves a different user id, actually it calls that a Provider Key.
- (Minor problem) For some reason, using the above link code, I don't get the user email but only his Facebook token and Facebook user id.
Please note, * I want to use the native approach and can't use a web view on the mobile app because I want the app to use the user Facebook/google native application. * Also read this: ASP.NET Identity in Microservice Architecture it didn't work.
Thanks in advance! Shaul