Пример #1
0
        public async Task <IActionResult> FacebookLogin(SocialNetworkIdTokenModel data)
        {
            var facebookAPIResponce = await _authenticateWrapper.GetFacebookToken(data.IdToken);

            if (facebookAPIResponce != null)
            {
                var facebookUserInfo = await _authenticateWrapper.GetFacebookUserData(facebookAPIResponce.id, data.IdToken);

                _serviceAuth.SocialNetworksAuthenticate(facebookUserInfo.email, facebookUserInfo.first_name,
                                                        facebookUserInfo.last_name, data.Url);

                var response = GiveJWTToken(facebookUserInfo.email, "0");

                return(Ok(response));
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #2
0
        public IActionResult GoogleLogin(SocialNetworkIdTokenModel data)
        {
            try
            {
                GoogleJsonWebSignature.ValidationSettings settings = new GoogleJsonWebSignature.ValidationSettings();
                settings.Audience = new List <string>()
                {
                    "752253873246-cg9qrlhp0tmtn7cd8vpg4qrfk03br55c.apps.googleusercontent.com"
                };
                GoogleJsonWebSignature.Payload userGoogle = GoogleJsonWebSignature.ValidateAsync(data.IdToken, settings).Result;

                _serviceAuth.SocialNetworksAuthenticate(userGoogle.Email, userGoogle.GivenName, userGoogle.FamilyName, userGoogle.Picture);

                var response = GiveJWTToken(userGoogle.Email, "0");
                return(Ok(response));
            }
            catch (Exception ee)
            {
                return(BadRequest(ee.Message));
            }
        }