❔ Which OAuth packages to choose for 3rd party user authentication?
There is three collections of nuget packages that i can see:
Owin.Security.Providers.[provider]
AspNet.Security.OAuth.[provider]
Microsoft.AspNetCore.Authentication.[provider]
I want the users to be able to authenticate by using their discord/twitter/google account, and my frontend is using SvelteKit so everything is just pure json api's
47 Replies
@OptoCloud r u there
yup
use these packages
Owin.Security.Providers.Discord: This package provides OAuth authentication support for Discord. It allows users to authenticate with their Discord account.
Owin.Security.Providers.Twitter: This package provides OAuth authentication support for Twitter. It allows users to authenticate with their Twitter account.
Owin.Security.Google: This package provides OAuth authentication support for Google. It allows users to authenticate with their Google account.
we have a chatgpt user here
??
its literally from google
you can literally google it and find the answer yourself
i know not to use those because they don't even work
liek it doesnt compile
like severly outdated
then use other packages
thats the exact response chatgpt gave me
it just assumed owin becuase of some info out there but later corrected itself once it realized it was outdated
you do realise chatgpt extracts its solutions from google right ?
right ?
yup
then whats the issue
whats your front end then ?
what is it using
sveltekit
json ?
json
oh idk then
what
both of them ?
sveltekit that requests json from backend
ok makes sense
did you specify the client ID?
for google you can use Microsoft.AspNetCore.Authentication.Google
i tried it
Microsoft.AspNetCore.Authentication.Twitter
twitter
it does not provide the right package
AspNet.Security.OAuth.Discord 7.0.2
ASP.NET Core security middleware enabling Discord authentication.
this looks good for discord
this is where i start to wonder, why the name change
one is aspnet the other is aspnetcore
can both work
or different use cases?
prob because of legal reasons
who is the op here
me
yes both can work
one is official from microsoft
you can see the sticker
the other is not
but both are published to nuget by ms?
no
nope
oh
if it's Microsoft.* it's from microsoft
i was thinking this
aspnetcore
Thanks, figured out the most of it now although some stuff is still really weird
Will send that later
But getting bunch of cors errors
cors error are to be expected
you need to configure it properly
ok so i do this atm
Extension method:
problem is
after any oauth flow has finished creating its ticket
it calls my authentication middleware, where the logic within it is not supposed to handle that kinda data
so in the SignInAsync method in there i do this:
and then all this:
so short:
client calls oauth init endpoint
client gets redirected to oauth provider
cient gets redirected to callback endpoint
callback handler handles the response and gets the secrets, fetches the necessary info, creates a ticket
then
the ticket the remoteauthenticationhandler created gets passed into my main authenticationhandler
main authenticationhandler checks if the authenticationscheme passed into it matches the expected
If not it calls some custom oauth static methods i wrote which will parse that data and do some db calls to create the user if it doesnt exist, then return that to the authentcation handler
@Henkypenky
this seems
overly complicated
can't i just have my own authenticationhandler just for the oauth, seperate from the main one?
authentication is complicated
if it works let it be
btw that looks pretty good if you ask me, maybe someone else knows how to do it better
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.@Henkypenky
my app is behind that
and when it tries to do the callback
the oauth2 tries to call back to:
http://api.optocloud.no/api/v1/auth/o/cb/google
http, not https
im trying to get it to do https
but it doesnt want to