Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web API 2 RegisterExternal Account with existing access token

Using the Facebook iOS SDK I have received an access_token for the user of my iOS application which allows me to view their basic profile information. I would like to use that token to register & login users against my existing web application.

I don't want the user to navigate to the account/ExternalLogins URL and be redirected from there in a WebView as at this point I already have the access token that provides. What I don't understand is how I can make use of the Acccount/RegisterExternal or Account/AddExternalLogin methods and provide them with this existing token and a username/email to register a new user. All of my attempts have been met with 400 or 500 errors.

I've checked a lot of stack overflow answers and blog posts but they seem to roll-your-own or modify existing methods in the AccountController. But I don't see why doing either of these things are necessary when it looks like everything is already there for you. I'm just not sure how I can make use of it!

Any help would be greatly appreciated.

Edit: I ended up using this custom solution by codetrix. It's not what I originally wanted but it was simple to include and works so far. If anyone is able to answer the original question then please do.

like image 526
bean Avatar asked Aug 30 '25 18:08

bean


1 Answers

If you already have the token and can view the information, use an instance of the UserManager to push that information to. That's essential what your codetrix solution is doing, but you can do the same.

The endpoints your referencing just have those setup already, so view that code to see how it's invoking the UserManager and work the same functionality out where you need it.

like image 177
Greg Avatar answered Sep 04 '25 18:09

Greg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!