✅ 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
What are you trying to connect with the oauth
Like are you doing a backend to backend or is it a client
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?
A client
A desktop one?
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
You will need to spin up a webserver in you client so you can listen to the callback from the oauth
Webserver? Like ASP.NET...? Or some other kind of server?
A simple httplistener is enough
I'm aiming for this to be a simple CLI tool, so it's not gonna be long-running.
And the listener just need to stay alive for the auth process
ah
When it's done and you have the token it is fine
So I set up an HTTP listener for the auth process, then discard it when it's done?
Yeah.
And for handling 80% of the process (except the httplistener part hahaha) you can use something like IdentityModel https://identitymodel.readthedocs.io/
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?