Dave Demirkhanyan
Dave Demirkhanyan

Reputation: 570

How to extract facebook access token from URL

The title of the question is perhaps misleading but I couldn't find any other way to state the question, any suggestions in the commentary section is welcome, previously I asked on SO how to make facebook authentication from scratch and basically I resolved that problem.

    public ActionResult Index()
    {
        return View(); 
    }

    public ActionResult Login()
    {
        string URL = "https://www.facebook.com/dialog/oauth?client_id={app-id}&redirect_uri={redirect-uri}&response_type=token";
        return Redirect(URL);
    }

The index view just consists of one line:

<a href="~/Home/Login">Login</a>

And it logs in perfectly well, but I can't figure out how to grab the accesstoken, in the manual on facebook they say that it will be included in the URL but after it redirects to the localhost it certainly does not. I suppose this should be easy, but I am stuck. Any suggestions ?

Upvotes: 0

Views: 297

Answers (1)

andyrandy
andyrandy

Reputation: 73984

https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.2#login

See "Handling login dialog response".

You have to set the response type to "token", you actually wrote "responce_type" instead of "response_type".

Btw, i highly suggest using the JS SDK for Login, it´s a lot easier to handle.

Upvotes: 1

Related Questions