Example #1
0
        public override async Task <User> GetUserSocialNetworkByTokenAsync(string token)
        {
            RequestInfo requestInfo = new RequestInfo
            {
                UrlBase = $"{QueryString}{token}"
            };

            var responseData = await RequestAPI.ConnectRestAPI(requestInfo, MethodType.GET);

            var user = new User();

            if (responseData.Code == ApiStatusCode.Ok && !string.IsNullOrEmpty(responseData.Data))
            {
                var userGooogle = ConvertJson.Deserialize <UserGoogleInfo>(responseData.Data);

                user.FullName        = ($"{userGooogle.GivenName} {userGooogle.FamilyName}").Trim();
                user.UserName        = userGooogle.Name;
                user.SocialNetworkId = userGooogle.Sub;
                user.Email           = userGooogle.Email;
                //user.Gender
                user.Avatar = userGooogle.Picture;
            }

            return(user);
        }
        public override async Task <User> GetUserSocialNetworkByTokenAsync(string token)
        {
            RequestInfo requestInfo = new RequestInfo
            {
                UrlBase = $"{QueryString}{token}"
            };

            var responseData = await RequestAPI.ConnectRestAPI(requestInfo, MethodType.GET);

            var user = new User();

            if (responseData.Code == ApiStatusCode.Ok && !string.IsNullOrEmpty(responseData.Data))
            {
                var userFacebook = ConvertJson.Deserialize <UserFacebookInfo>(responseData.Data);

                user.FullName        = userFacebook.Name;
                user.UserName        = userFacebook.Email;
                user.SocialNetworkId = userFacebook.Id;
                user.Email           = userFacebook.Email;
                //user.Gender = userFacebook.Gender;
                user.Avatar = userFacebook.Picture?.data?.url ?? string.Empty;
            }

            return(user);
        }