public async Task <ActionResult> FacebookCallback(string code) { try { var fb = new FacebookClient(); var appId = _configuration["FACEBOOK_APP_ID"]; var secret = _configuration["FACEBOOK_APP_SECRET"]; //dynamic result = fb.Post("oauth/access_token", new //{ // client_id = appId, // client_secret = secret, // redirect_uri = RedirectUri.AbsoluteUri, // code = code //}); var tokenParams = HttpUtility.ParseQueryString(fb.GetAccessToken((string)JObject.Parse(code)["code"], appId, secret)); var accessToken = tokenParams["access_token"]; // update the facebook client with the access token so // we can make requests on behalf of the user fb.AccessToken = accessToken; var facebookService = new FacebookService(fb); var getAccountTask = facebookService.GetAccountAsync(accessToken); Task.WaitAll(getAccountTask); var account = getAccountTask.Result; return(Ok(new ProfileViewModel(account))); } catch (Exception ex) { return(BadRequest("Server Error")); } }