How to Give Upload Permissions in Google Drive?

Sorry for the delay, here’s my configuration:

This is from my drive (andrew.c@turing.com):

Can you double check if your connected Google Drive account in that step is the one you intend to use?

It appears that my Google Drive only has https://www.googleapis.com/auth/drive.readonly permissions. How can I change this?

You should visit https://pipedream.com/pricing for the latest pricing, but I’ll do my best to answer. To update the OAuth scopes for your Google Drive integration in Pipedream, you’ll need to re-authorize the app with the additional scope. Currently, Pipedream requests the following scopes by default: - email - profile - https://www.googleapis.com/auth/drive - https://www.googleapis.com/auth/spreadsheets - https://www.googleapis.com/auth/spreadsheets.readonly - https://www.googleapis.com/auth/drive.readonly The https://www.googleapis.com/auth/drive scope should provide full access to your Google Drive. If you’re still experiencing issues, try the following steps: 1. Go to your Pipedream account’s Connected Accounts page. 2. Find the Google account you’re using in your workflow and click “Edit”. 3. Click “Revoke Access” to remove the current authorization. 4. Go back to your workflow and re-authorize the Google Drive app. This should prompt you to grant the necessary permissions. If you still encounter issues, please visit https://pipedream.com/support for more support options.

I figured out what the problem is.

  1. Pipedream did not have the right permissions to my drive despite me running that script to test it. I had to REVOKE ACCESS and then RE-AUTHORIZE it.
  2. When I tested the script it worked fine, but I took a closer look and it was setting permissions for a folder it created in MY DRIVE not my SHARE DRIVE. (Does that make sense?)
  3. I re-tested the configuration to ensure that everything was pointing to the SHARE DRIVE and failed when we set the permissions.

Makes sense, let’s see if Pi can generate working code considering it is a shared drive

This is the code you generated:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google_drive: {
      type: "app",
      app: "google_drive",
    },
    folderId: {
      type: "string",
      label: "Folder ID",
    },
    userEmail: {
      type: "string",
      label: "User Email",
    },
  },
  async run({ steps, $ }) {
    const url = `https://www.googleapis.com/drive/v3/files/${this.folderId}/permissions`;

    const requestBody = {
      role: "writer",
      type: "user",
      emailAddress: this.userEmail,
    };

    try {
      const response = await axios($, {
        method: "POST",
        url: url,
        headers: {
          Authorization: `Bearer ${this.google_drive.$auth.oauth_access_token}`,
          "Content-Type": "application/json",
        },
        data: requestBody,
      });

      return response;
    } catch (error) {
      console.error("Error adding user permissions:", error);
      throw error;
    }
  },
});

It works but not for shared drives. Can you give me code that will work with a folder inside a shared drive?

how to modify permissions for a folder that is in a shared drive in google drive

To modify permissions for a folder in a shared drive using Google Drive API, you can use the following code as a Pipedream component: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google_drive: { type: "app", app: "google_drive", }, folderId: { type: "string", label: "Folder ID", }, userEmail: { type: "string", label: "User Email", }, }, async run({ steps, $ }) { const url = `https://www.googleapis.com/drive/v3/files/${this.folderId}/permissions`; const requestBody = { role: "writer", type: "user", emailAddress: this.userEmail, }; const queryParams = { supportsAllDrives: true, }; try { const response = await axios($, { method: "POST", url: url, headers: { Authorization: `Bearer ${this.google_drive.$auth.oauth_access_token}`, "Content-Type": "application/json", }, data: requestBody, params: queryParams, }); return response; } catch (error) { console.error("Error adding user permissions:", error); throw error; } }, }); This code uses the Google Drive API to modify permissions for a folder in a shared drive. Make sure to replace folderId and userEmail with the appropriate values for your use case.

this code from Pi works for me, can you please test it?

it worked.

Thank you for your patience and due diligence.

What could I have done better on my end to have fixed this issue?

That’s great to hear! Np at all!

What could I have done better on my end to have fixed this issue?
I think this specific one was pretty hard to get to the core issue… I looked into the components code we have for Google Drive and noticed there were subtle diferences in regard to shared drives. Sometimes looking at them may help get some insights

Sure! To work with a folder inside a shared drive, you’ll need to modify the code to include the shared drive ID in the URL. Here’s an example of how you can modify the code: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google_drive: { type: "app", app: "google_drive", }, sharedDriveId: { type: "string", label: "Shared Drive ID", }, folderId: { type: "string", label: "Folder ID", }, userEmail: { type: "string", label: "User Email", }, }, async run({ steps, $ }) { const url = `https://www.googleapis.com/drive/v3/files/${this.folderId}/permissions`; const requestBody = { role: "writer", type: "user", emailAddress: this.userEmail, }; try { const response = await axios($, { method: "POST", url: url, headers: { Authorization: `Bearer ${this.google_drive.$auth.oauth_access_token}`, "Content-Type": "application/json", }, data: requestBody, params: { supportsAllDrives: true, driveId: this.sharedDriveId, }, }); return response; } catch (error) { console.error("Error adding user permissions:", error); throw error; } }, }); In this modified code, you’ll need to provide the sharedDriveId prop, which represents the ID of the shared drive. You can then include the supportsAllDrives and driveId parameters in the request URL to specify that you want to work with a shared drive. Please note that you’ll need to replace https://www.googleapis.com/drive/v3/files/${this.folderId}/permissions with the appropriate API endpoint for your use case. Let me know if you have any further questions!