JDashney
JDashney

Reputation: 11

Python Goole Drive API Disable Link Sharing & "Advanced Permissions"

Can someone please tell me if it is possible to do the following, and if so, point me in the right direction please:

TLDR: When I share the folder to a specific "user" as a "reader" I don't want link sharing to be turned on but it is. "Anyone at My_Org who has the link can view"

I have dug through the docs and posts and cannot find how to do it.

Code Below.

I am creating folders with:

def createFolder(name,sharewith):
    file_metadata = {
    'name': name,
    'parents': ['----------------------------------------'],
    'mimeType': 'application/vnd.google-apps.folder'
    }

    file = service.files().create(body=file_metadata,
                                        fields='id').execute()

    fid = file.get('id')
    return fid

Then Sharing the folder with a specific individual:

def insert_permission(service, file_id, emailAddress, perm_type, role, notif):
  new_permission = {
      'emailAddress': emailAddress,
      'type': perm_type,
      'role': role
  }
  try:
    return service.permissions().create(
        fileId=file_id, 

    body=new_permission,sendNotificationEmail=notif).execute()
    except errors.HttpError as error:
        print('An error occurred: %s' % error)
    return None

Edit: I see this - newPermission.setType("anyone"); in Set file sharing level to 'Anyone with the link' through Google Drive API

I want to do the opposite but can't find the acceptable parameters for setType()

Upvotes: 0

Views: 449

Answers (1)

JDashney
JDashney

Reputation: 11

As per my code I'm creating all these folders within a parent folder. For now I have changed the setting on the parent folder to be private and the children that my code creates all inherit that setting.

This solves the problem but if someone does have an actual code answer please feel free to provide it.

Upvotes: 1

Related Questions