public async Task<ActionResult> ImportLinkedIn() { var userManger = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())); var user = userManger.FindById(this.User.Identity.GetUserId()); var claim = user.Claims.SingleOrDefault(m => m.ClaimType == "LinkedIn_AccessToken"); if(claim == null) { // Redirect to connect LinkedIn // Drop a session nugget to get us back here Session["LinkLoginRedirect"] = "/Profile/ImportLinkedIn"; return new Resume.Controllers.AccountController.ChallengeResult("LinkedIn", Url.Action("LinkLoginCallback", "Account"), User.Identity.GetUserId()); } var client = new LinkedInApiClient(HttpContext.GetOwinContext().Request, claim.ClaimValue); var profileApi = new LinkedInProfileApi(client); var liProfile = await profileApi.GetBasicProfileAsync(); // Convert the LinkedIn api object into something eaiser to bind to the view var importVM = new ImportLinkedInViewModel(); importVM.FirstName = liProfile.FirstName; importVM.LastName = liProfile.LastName; importVM.Summary = liProfile.Summary; importVM.Positions = liProfile.Positions.Select(p => new Position() { Company = p.Company.Name, StartDate = new DateTime(p.StartDate.Year ?? DateTime.Now.Year, p.StartDate.Month ?? 1, p.StartDate.Day ?? 1), EndDate = p.EndDate == null ? (DateTime?)null : new DateTime(p.StartDate.Year ?? DateTime.Now.Year, p.StartDate.Month ?? 1, p.StartDate.Day ?? 1) }).ToList(); return View(importVM); }
public static LinkedInBasicProfile GetBasicProfile(string token) { var client = new LinkedInApiClient(HttpContext.Current.GetOwinContext().Request, token); var profileApi = new LinkedInProfileApi(client); LinkedInBasicProfile userProfile = profileApi.GetBasicProfileAsync().Result; return userProfile; }
protected override async Task<object> Extract() { var profileApi = new LinkedInProfileApi(client); var userProfile = await profileApi.GetFullProfileAsync(); return userProfile; }
public async Task <ActionResult> Index() { var userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); var user = userManager.FindById(this.User.Identity.GetUserId()); var claim = user.Claims.ToList().Where(m => m.ClaimType == "LinkedIn_AccessToken").SingleOrDefault(); var client = new LinkedInApiClient(HttpContext.GetOwinContext().Request, claim.ClaimValue); var profileApi = new LinkedInProfileApi(client); var userProfile = await profileApi.GetFullProfileAsync(); return(View(userProfile)); }
public async Task<ActionResult> Index() { var userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>(); var user = userManager.FindById(this.User.Identity.GetUserId()); var claim = user.Claims.ToList().Where(m => m.ClaimType == "LinkedIn_AccessToken").SingleOrDefault(); var client = new LinkedInApiClient(HttpContext.GetOwinContext().Request, claim.ClaimValue); var profileApi = new LinkedInProfileApi(client); var userProfile = await profileApi.GetFullProfileAsync(); return View(userProfile); }
public async Task<ActionResult> About() { ViewBag.Message = "Your application description page."; var am = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>(); var user = am.FindById(this.User.Identity.GetUserId()); var claim = user.Claims.ToList().Where(m => m.ClaimType == "LinkedIn_AccessToken").SingleOrDefault(); var client = new LinkedInApiClient(HttpContext.GetOwinContext().Request, claim.ClaimValue); var profileApi = new LinkedInProfileApi(client); var userProfile = await profileApi.GetBasicProfileAsync(); return View(); }
public async Task <ActionResult> About() { ViewBag.Message = "Your application description page."; var am = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); var user = am.FindById(this.User.Identity.GetUserId()); var claim = user.Claims.ToList().Where(m => m.ClaimType == "LinkedIn_AccessToken").SingleOrDefault(); var client = new LinkedInApiClient(HttpContext.GetOwinContext().Request, claim.ClaimValue); var profileApi = new LinkedInProfileApi(client); var userProfile = await profileApi.GetBasicProfileAsync(); return(View()); }
public LinkedInBasicProfile GetBasicProfile(string accessToken) { if (string.IsNullOrEmpty(accessToken) == true) { throw new ArgumentNullException(nameof(accessToken)); } // LinkedInBasicProfile ret = null; // using (var client = new LinkedInApiClient(this.OwinContext.Request, accessToken)) { var profileApi = new LinkedInProfileApi(client); var task = profileApi.GetBasicProfileAsync(); task.Wait(LinkedInSettings.Default.Timeout); ret = task.Result; } // return(ret); }