Using the web interface of Google Drive, I right-click on the file, select "sharing" to go to "Sharing settings". I installed the file in "Publishing on the Internet - anyone on the Internet can find and watch."
Then I copy the Share link, in which case it is: https://docs.google.com/open?id=0B6Cpn8NXwgGPbFBPMEh5VHc1cUU
Then click Finish.
If I open another browser, not cookies and try to visit the link, I am redirected to the login page for Google. I assumed that this option means that authentication is not required to view the file. Is this expected behavior?
I try to do the same through the API, and I do not get the expected result either when setting permissions for the public, setting someone as a reader, and using the webContentLink value for the file as the published URL. Also in this case, if I go to the link when you are not logged into Google Apps, I will be redirected to the entrance.
I call the following method to set permissions using this:
thePermission = insert_permission(userNickName,file['id'],"me","anyone","reader")
method:
def insert_permission(userNickName,file_id, value, perm_type, role): credentials = get_stored_credentials(userNickName) service = CreateDrive(credentials) if service is None: return """Insert a new permission. Args: service: Drive API service instance. file_id: ID of the file to insert permission for. value: User or group e-mail address, domain name or None for 'default' type. perm_type: The value 'user', 'group', 'domain' or 'default'. role: The value 'owner', 'writer' or 'reader'. Returns: The inserted permission if successful, None otherwise. """ new_permission = { 'value': value, 'type': perm_type, 'role': role } try: return service.permissions().insert( fileId=file_id, body=new_permission).execute() except errors.HttpError, error: print 'An error occurred: %s' % error return None
I am asking about the user interface UI mainly in this question, since it seems simpler to find out if I expect the correct result using what Google did.