im_blind
im_blind
CC#
Created by im_blind on 6/16/2024 in #help
Google Token
[HttpPost("google-login")] public async Task<IActionResult> GoogleLogin([FromBody] GoogleUserLoginDTO model) { var payload = await GoogleJsonWebSignature.ValidateAsync(model.Token); var a = payload. if (payload == null) { return BadRequest("Invalid Id Token"); } var user = await _userManager.FindByEmailAsync(payload.Email); if (user == null) { user = new AppUser { Email = payload.Email, UserName = payload.Email, Name = payload.Name, Avatar = payload.Picture, }; var result = await _userManager.CreateAsync(user); if (!result.Succeeded) { return BadRequest("Failed to create user"); } } await _signInManager.SignInAsync(user, isPersistent: false); var token = _tokenService.CreateToken(user); return Ok(new GoogleUserLoginDTO { Token = token }); } quick question, so what im trying to do is to receive a token from google, extract only some of the information (ex: only email and name) and then make another token to send em back to my react buddies. I tested swagger and it returned a normal token just fine. But debugging Front End led to Bad Request 400
1 replies
CC#
Created by im_blind on 6/7/2024 in #help
Trouble implementing Identity
Hi so basically, I'm making a asp .net core web app and i want to use JWT and Identity (cause i heard google api for login, opts,.. are good) Thing is, the Database has already been constructed before hand and used scaffold to generate them in my .net project Therefore I already got a User entity. I watched some vids on yt guiding that I should extend the IdentityContext, IdentityUser, write stuff in program.cs files and how to use them in controllers. But these 2: IdentityContext, IdentityUser i've only extended, that's it One more problem is that, some recommended creating ApplicationUser? but I already have my User so is it needed? I then made my own login controller, and ran on swagger. It returned this { Invalid column name 'NormalizedUserName'. Invalid column name 'Id'. Invalid column name 'AccessFailedCount'. Invalid column name 'ConcurrencyStamp'. Invalid column name 'EmailConfirmed'. Invalid column name 'LockoutEnabled'. Invalid column name 'LockoutEnd'. Invalid column name 'NormalizedEmail'. Invalid column name 'NormalizedUserName'. Invalid column name 'PasswordHash'. Invalid column name 'PhoneNumberConfirmed'. Invalid column name 'SecurityStamp'. Invalid column name 'TwoFactorEnabled'. Invalid column name 'UserName'. } Now some told me that it's DB related and suggested I migrate add Identity and then update the Database but then I got errors from the tables constructed before Is Identity really needed for outside apis like google,....? If yes, how should i fix this? If no, what should I do instead?
103 replies