When you add this scope inside oauthScopes section in your appscript.json file:
"oauthScopes": [
"https://www.googleapis.com/auth/script.webapp.deploy",
]
you will see something like this when you attempt to use the addon:
As I understand, this scope will allow the developer to deploy the addon as a web app (a separated web app for each addon user, not the only web app when we Deploy as web app manually in the script editor)
My question is how to actually use this scope to "Publish this application as a web app" ?
I mean in code it must be ScriptApp.deployWebApp(...) or something like that, right?
But I can't find anything here https://developers.google.com/apps-script/reference/script/script-app
I am afraid it currenty is not possible. Ass see in ScriptApp.Service class, you can only disable Web app for script, read their URL, but create new one.
Related
My question is exactly like this question but I think I am missing something because I can't seem to follow the marked answer. So to clear things up:
I have a GCP project, my-drive-project that has configured Drive UI integration, setting "Open with" url to my website https://www.example.com/open-drive (there is also New Url but I think it's similar).
My website at https://www.example.com/open-drive has Javascript code to read state parameter as per Handle a New URL and Handle an Open URL.
Now how do I test my website to make sure the code at https://www.example.com/open-drive is correct? How do I get the "Open With" menu in my Drive?
As I understand I need to somehow install an unpublished Google Workspace App, but how do I do that? In this case, clearly I am not using any App Script so the answer in the linked question confuses me greatly.
I found out Alternate Runtime but the deployment.json doc confuses me as well as I cannot find any information on how to fill it in. I took the sample JSON there, delete all services but drive, tried Installing it but I do not see the menu anywhere. Also I believe this is for an add-on app which I think my app is not (because the website simply receive a request and process it, not modifying any UI of Drive). Below is my current config:
{
"oauthScopes": ["https://www.googleapis.com/auth/drive.file"],
"addOns": {
"common": {
"name": "My App",
"logoUrl": "https://fonts.gstatic.com/s/i/googlematerialicons/markunread_mailbox/v6/black-24dp/1x/gm_markunread_mailbox_black_24dp.png",
"homepageTrigger": {
"runFunction": "https://www.example.com"
}
},
"drive": {
}
}
}
I just tested Google Drive UI Integration blind, like #Luke Vo. It is still not listed / approved in the Workspace Marketplace. However I just noticed the integration in Google Drive under the account I used for testing.
My guess it, what is required for testing:
configured Drive UI integration
run your oauth flow once with scopes for 'https://www.googleapis.com/auth/drive.install', 'https://www.googleapis.com/auth/drive.file'
wait... the docs mention regarding icons "Icons can take up to 24 hours to appear in Drive" So I assume it may take a few hours for changes to propagate through the system.
I only noticed it days later when I was ready to submit it to the Workspace Marketplace. For good measure you may also wanna pre-fill all the Workspace Marketplace details to the point that you could hit submit any time.
I found out that from your page https://example.com, if you request https://www.googleapis.com/auth/drive.install scope, the app get installed and you get the menu from Google Drive.
So the scope should be something like this (space-delimited):
https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.install
I didn't have drive.install scope before.
Previous answer:
As a temporary workaround, I wrote this web page to simulate the state parameter: https://datvm.github.io/DriveUiIntegrationTest/. The repo source code and documentation is here: https://github.com/datvm/DriveUiIntegrationTest.
Basically it uses Picker API to grant permission of files or a folder to your app and then redirect to the app URL with documented state parameter:
I have written an Apps Script for personal use that I want to invoke with an HTTP request. (I'm basically using this like a "serverless function" with native authentication to Google Apps APIs.)
I can do this easily by deploying my Apps Script project as a Web App, which gets me a URL like
https://script.google.com/macros/s/${DEPLOYMENT_ID}/exec
However, if I make changes to my script and want to push those changes live, I have to create a new deployment, which will have a new deployment ID, thus changing the URL.
I know that I could use a "Test Deployment" to get a URL that always points to the project HEAD, but this always requires authentication from the HTTP client. With my deployment, I can set "Who has access" to "Anyone" and avoid this requirement.
Is it possible to deploy a web app script to a URL that will not change on future deployments?
In the old editor deploying to the same URL is the default behavior because you can only have one deployment. The new editor allows you to have multiple deployments, each with its own URL and (possibly) pointing to different versions of your application.
To update an existing deployment to a different version, or to create a new version, you need to edit your deployment's configuration.
Editing deployment configuration
I'm trying to develop a simple web app using google script web app service and access it from another script using the UrlFetch service.
My problem is that in order to try the code on my web app I have to publish a new version every time because trying to access to the dev URL returns returns and HTML file telling me to sign in even though I've set the permissions for the web app to everyone, including anonymous (if I hit the production URL it does work, though).
I'm assuming that Google is limiting the access to the dev URL for security reasons but can someone shed a light on that assumption?
PS: I don't know if this is relevant but my google account is in a Google Apps for Education domain
Edit
I've found a method to avoid publishing the application for each code change: instead of calling it from the UrlFetch service, I've created a function in the web App code that does call the doPost or the doGet method (I've to create the request param, but that's easy) and I've changed the end of the script to log the result insted of returing it to the client. When the application will be ready, I can publish and develop the client using the UrlFetch.
Anyhow, if anyone knows about the limitation of the dev URL that would be great!
your assumption is correct, the dev url ignores your publishing permissions on purpose, only the developer has access to that url.
you could accomplish what you want using libraries. move the code in your called script to a library and add it to that script as "development mode" and publish your script service.
changing library code should also change your service because its on development mode.
Note that this can easily break your app if you save partial code changes, and makes it hard to test your changed code unless you make all changes and tests in a separate script copy. Making several changes at once in multiple apps script editor files is possible with their "Save all" File menu command (after manually pasting all code changes from your tested copy).
I am developing a one of those bulk delete script for gmail. I want to create a front end for the script so I can easily modify my settings on a per-label basis to specify how many emails I want to delete during a trigger event and how old they have to be for a particular label. I want to be able to test the interface similar to testing a script.....just hit the run button. However, google's script engine tells me I need to deploy the script and it's HTML files as a web app to test the interface.
Is there anyway to test the the interface and its interaction with my backend google script without deploying as a web app?
The answer is no, unless you "deploy" your code through a Spreadsheet. In fact, it's fairly well-documented.
See Serve HTML as a Google Docs, Sheets, or Forms user interface on that page for a "workaround" to testing your app without actually deploying it.
However, there is no harm in deploying it as a webapp. And as a matter of fact, you can see changes instantly after refreshing your app that you have deployed (published), using the dev macro you're given when you deploy it. This is the most useful tool for UiApp and HTMLService:
Edit: After you're done testing and you've "finalized" your code, you can disable the webapp, meaning that nobody can accidentally access it, you don't post the macro link to it, etc. It's a one-click process. Again, this is really the only way to test the code in my opinion, as it's most succinct for a real "development process". See image below:
I deployed a web app from a Google Apps Script, but others don't seem to be able to run it.
(It runs fine for me when logged-in to Google)
I keep getting "Request to share" email, even though I set the source script to be "Public on the Web".
"Execute the app as:" is set to "User accessing the web app".
A link to the app is at http://truevis.com/rations
It could be very useful to others, but right now I think that no one else can run it.
The link you show here is the development link , the one that is described as "the last saved version of your code", this link is not shareable ... the one you should give to people is this one :
https://script.google.com/macros/s/AKfycbz1SKJi5HW1r2ZHiYpjedjul-IE4vcB266kdDzDrVCE/exec
it is shown in this popup window
beside that, the sharing properties of the script file is not relevant, you could keep it private.... only the settings in this window are important to determine who has access to your app and how (meaning run as you or as user accessing the app).
You should also keep in mind that users will see the version you have chosen in this same popup window, no matter the changes you could have saved and are using in your .dev version... so think about publishing the right version.
What I did to get it working:
I copied the GS code to a new file, deployed as Web app, then set "Execute the app as:" "me", "Who has access to the app:" "anyone even anonymous".
https://script.google.com/macros/s/AKfycbwPtys8PE8Wda_HS9rvrdftJ0TGbCfMlT5xLlfsNFt9m5uw6qM/exec
I think once you deploy a version with certain permission, it does not work properly if you change the permission for the same version.
Creating a new version seems to solve the problem