google-drive-apigoogle-workspacegoogle-workspace-add-ons

How to test Google Drive UI Integration "New" and "Open With"?


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:

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": {
    }
  }
}

Solution

  • 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:

    enter image description here