I'm developing a desktop app that makes uses of Google Sheet API v4. Within the app's Project in the GCP console, the scopes for the OAuth consent screen are the following:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/userinfo.email
I'm able to get an OAuth access token (plus a refresh token) from my desktop app via the authorization code flow. I can get the list of Spreadsheets and all their tab names, etc via cURL calls when I add the access token as a Authorization : Bearer {{token}}
header.
Now, I have written a simple Google Apps Script that I associated with the desktop app's project in the GCP console using the "Resources > Cloud Platform Project" menu item. Then, I deployed the Apps Script as a Google Web App with the following settings within the "Publish > Deploy as web app" dialog:
Execute the app as: User accessing the web app
and
Who has access to the app: Anyone
The manifest for the Google Apps Script Web App contains the following for OAuth Scopes:
"oauthScopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/userinfo.email"]
Now, I figured that since the desktop app scopes are the same as the deployed Web App, the access token I retrieve from the initial authorization code flow would be enough to grant the end-user permission to access and use the Web App. However, when I test the Web App by making a call to it via cURL, I am met with a response that says:
Drive
You Need Permission
Want In? Ask for access, or switch to an account with permission. Learn more
You are signed in as end-user@sampledomain.com
Based on the You are signed in as...
statement, the Web App permission screen does "know" the desktop app's end-user email address.
Is it possible to use the initial access token the end-user retrieved via my desktop app to successfully interface with the deployed Web App? Or, does the end-user need to authorize BOTH the desktop app (to retrieve the Drive Spreadsheet files, etc.) AND the Web App that queries and updates the sheet? I would prefer that the user NOT have to grant permission twice. Is it possible to have the user grant permission to ONLY the desktop app which would also grant permission to the Web App?
If the end user MUST grant permission to both the desktop app and the Web App, I'm not sure how to retrieve an access token from the Web App permission screen. If the end user grants access to the Web App explicitly, does that permission last forever for that particular user's email? I'm not certain we can use a OAuth authorization code flow for a deployed Web App.
Any insight or guidance is appreciated!