Пример #1
0
        /// <summary>
        /// Check if LinkedIn token is expired
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool IsLinkedInTokenExpired(SocialMediaAuthorizeModel model)
        {
            try
            {
                var linkedInHelper = new LinkedInHelper(model.AccessToken);

                var userInfo = linkedInHelper.GetCurrentUser();
            }
            catch (Exception)
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Get LinkedIn account info
        /// </summary>
        /// <param name="model"></param>
        /// <param name="callbackUrl"></param>
        /// <returns></returns>
        public static SocialMediaResponseModel GetLinkedInAccountInfo(SocialMediaResponseModel model, string callbackUrl)
        {
            model.Verifier = HttpContext.Current.Request["code"];

            DateTime expiredDate;

            // Get access token and expired date
            model.AccessToken = LinkedInHelper.GetAccessToken(model.AppId, model.AppSecret, model.Verifier, callbackUrl, out expiredDate);

            model.ExpiredDate = expiredDate;

            #region Get User Profile

            var linkedLinkHelper = new LinkedInHelper(model.AccessToken);

            var userInfo = linkedLinkHelper.GetCurrentUser();

            model.FullName = StringUtilities.GenerateFullName(userInfo.FirstName, userInfo.LastName);
            model.Email    = userInfo.Email;

            #endregion

            return(model);
        }