title: Getting Facebook user access token from Facebook SDK for .Net in ASP.Net MVC app
body: <p>I'm mostly using a template from a MVC app that sets up the Facebook login and register process. I can register and log in using facebook, but when I register I want to pull additional data (gender, birthday, etc) from the Facebook user so I don't have to ask them to do it manually. This will be done in .Net, so I'm trying to use the Facebook .Net SDK but I don't know how to get the users access token from the template code that Visual studiio has set up for me. Here is my code. Take a look at var accessToken = ??
  "var info" has some data coming back from facebook, like the provider key, but no access token or user id. This method below is after the user has entered in their Facebook credentials. </p>
  
  <pre><code> [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public async Task&lt;ActionResult&gt; ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
      {
          if (User.Identity.IsAuthenticated)
          {
              return RedirectToAction("Index", "Manage");
          }
  
          if (ModelState.IsValid)
          {
              // Get the information about the user from the external login provider
              var info = await AuthenticationManager.GetExternalLoginInfoAsync();
              if (info == null)
              {
                  return View("ExternalLoginFailure");
              }
              var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, MembershipCreated = DateTime.Now }; //{ UserName = model.UserName, Email = model.Email, MembershipCreated = DateTime.Now, Gender = model.Gender, Birthdate = birthdayDateTime };
              var result = await UserManager.CreateAsync(user);
              if (result.Succeeded)
              {
                  result = await UserManager.AddLoginAsync(user.Id, info.Login);
                  if (result.Succeeded)
                  {
                      await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
  
                      //try to create profile here
                      var accessToken= //need to get access token here!!!
                      FacebookClient client = new FacebookClient(accessToken);
  
                      dynamic fbUser = client.Get("https://www.facebook.com/" + info.DefaultUserName);
  
                      if (returnUrl == "/Account/Register")
                      {
                          returnUrl = "/Home";
                      }
                      return RedirectToLocal(returnUrl);
                  }
              }
              AddErrors(result);
          }
  
          ViewBag.ReturnUrl = returnUrl;
          return View(model);
      }
  </code></pre>