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); }
public LinkedInResponse GetBasicProfile() { LinkedInResponse ret = new LinkedInResponse(); // try { using (LinkedInLogic linkedInLogic = new LinkedInLogic()) { ApplicationUser user = linkedInLogic.EnsureUserIsAuthenticated(); // string accessToken = linkedInLogic.GetAccessToken(user); if (string.IsNullOrEmpty(accessToken) == true) { throw new UserNotAuthenticatedException(); } // LinkedInBasicProfile profile = linkedInLogic.GetBasicProfile(accessToken); if (profile == null) { throw new ArgumentNullException(nameof(profile)); } // string json = JsonConvert.SerializeObject(profile); ret = new LinkedInResponse() { Status = "ok", ErrorMessage = null, RedirectUrl = null, JSON = json, }; } } catch (UserNotAuthenticatedException ex) { ret = new LinkedInResponse() { Status = "error", ErrorMessage = ex.Message, RedirectUrl = getChallengeRedirectUrl(), JSON = null, }; } catch (Exception ex) { ret = new LinkedInResponse() { Status = "error", ErrorMessage = ex.Message, RedirectUrl = null, JSON = null, }; } // return(ret); }