C
C#10mo ago
Thinker

✅ Authenticating using OAuth

Does anyone have any resources on authenticating using OAuth? I wanna interact with the Google Workspaces APIs which require OAuth authentication, but I have no idea how to properly set it up. I have the OAuth2 client secret and ID set up, I'm just unsure of how to use it.
33 Replies
Kao
Kao10mo ago
What are you trying to connect with the oauth Like are you doing a backend to backend or is it a client
Hazel 🌊💃
Hazel 🌊💃10mo ago
I'm not an expert, but I thought it was a simple system of auth with original token, get back auth token, refresh that when it expires?
Thinker
Thinker10mo ago
A client
Kao
Kao10mo ago
A desktop one?
Thinker
Thinker10mo ago
ye I've read through this article and think I get how it works, but there's not reference for how to authenticate and stuff. https://developers.google.com/workspace/guides/auth-overview
Kao
Kao10mo ago
You will need to spin up a webserver in you client so you can listen to the callback from the oauth
Thinker
Thinker10mo ago
Webserver? Like ASP.NET...? Or some other kind of server?
Kao
Kao10mo ago
A simple httplistener is enough
Thinker
Thinker10mo ago
I'm aiming for this to be a simple CLI tool, so it's not gonna be long-running.
Kao
Kao10mo ago
And the listener just need to stay alive for the auth process
Thinker
Thinker10mo ago
ah
Kao
Kao10mo ago
When it's done and you have the token it is fine
Thinker
Thinker10mo ago
So I set up an HTTP listener for the auth process, then discard it when it's done?
Kao
Kao10mo ago
Yeah. And for handling 80% of the process (except the httplistener part hahaha) you can use something like IdentityModel https://identitymodel.readthedocs.io/
Thinker
Thinker10mo ago
Oh also, while I'm at it, would there be a way to store the token somewhere persistent such that the user doesn't need to log in on every invocation of the tool?
Want results from more Discord servers?
Add your server