I've created an application with asp.net mvc api with users, following this tutorial. And everything works great like that.
Now I'm trying to add external logins (actually just Facebook). I've been looking how to do this and I found an answer here.
So I have the Startup.Auth.cs configured with Facebook AppId/Secret.
I make a call to GET api/Account/ExternalLogins?returnUrl=%2F&generateState=true
And then I redirect to the given Url. and then I'm returned to something like http://localhost:49728/#access_token= ... &token_type=bearer&expires_in=2592000&state= ...
And here is my problem. What should I do next to register the user on the website.
After the web application is complete, there will be a mobile native app.
EDIT
I changed the return url, to where I can ask and save the username.
So far good.
After I save the new user, I need to make the login, so I'm trying this:
var state = new RegExp('[\&&]state=([^&#]*)').exec(window.location.href);
$.get(baseurl + 'api/Account/ExternalLogin?provider=Facebook&response_type=token&client_id=self&redirect_uri=' + encodeURIComponent(baseurl) + '&state=' + state[1], function (data, status) {
console.log(data);
});
but I'm getting the 400 Bad Request error.
My question now is how can I fix this, and make the login?