✅ help me understand

I want to create a web api forum pet project, but only using google oauth for auth. I implemented the process of getting the access token from google, but i don't know how do i need to store user in db, so i can get all posts, info about user that wrote this post (like his pfp etc)
10 Replies
Angius
Angius6mo ago
Are you using Identity, or do you want to write the auth from scratch?
blueberriesiftheywerecats
Whatever makes me use user.claims and authorize attribute I really have both implemented and dont know which one is better
Angius
Angius6mo ago
Identity, then If you hooked up Google OAuth to Identity properly, then you can just use Identity as usual Assuming your DbContext inherits IdentityDbContext you can create a navigation property to IdentityUser in any other EF entity And query like that
blueberriesiftheywerecats
I connected google ouath through Authentication.Google package with AddAuthenticatio().AddGoogle method
Angius
Angius6mo ago
It should just work, then
blueberriesiftheywerecats
Does it create user automatically in db?
Angius
Angius6mo ago
When the user registers, yes Or, I guess in case of OAuth, when they log in for the first time Check the database and see if the user has been created
blueberriesiftheywerecats
If user changes google username, does it update the db next time he logins? Or pfp, etc
Angius
Angius6mo ago
IIRC what gets saved in the database is just the user identifier of some sort And all the data from their Google account are saved in the claims Each time on login Don't quote me on that, though