Is it possible to use Google OAuth and have no UI ever?
My thought is: save the account credentials and refresh token into a custom setting and keep calling that every time. So the flow would look something like:
- We Authorize with this URL: https://accounts.google.com/o/oauth2/auth?client_id=123456789&response_type=code&scope=https://www.googleapis.com/auth/theappweareusing&redirect_uri=/apex/testHTMLPage&access_type=offline
- Rather then redirecting us when we are done to testHTMLPage and getting back the code parameter with the authorization code in the URL, is is possible to pass back the authorization code in another way? I do not want to have to display any pages in order to get the code.
- Save the authorization code into a custom setting
- We take the authorization code from the custom setting and use it to exchange for the authorization token and refresh token
- Save the refresh token in a custom setting
- Once I have both of these tokens, I call the https://accounts.google.com/o/oauth2/token and pass it the token, the key, and the secret (no need for the redirect uri)
- I should get back a response status code of 200 and can move on from there
My end goal is to have a Trigger callout to a google api without any user interaction. I would like everything to seamlessly run in the background.