Using the Google Drive web interface, I right click on a file, select 'sharing', to get to "Sharing Settings." I set the file to "Public on the web - Anyone on the Internet can find and view."
I then copy the "link to share", in this case it is: https://docs.google.com/open?id=0B6Cpn8NXwgGPbFBPMEh5VHc1cUU
I then click "Done."
If I open another browser, no cookies, and try to visit the link, I am redirected to sign-in page for Google. I assumed this setting meant that no authentication would be required to view the file. Is this the expected behavior?
I am trying to do the same thing through the API, and I am not getting the expected result either when setting the permissions to public, setting 'anyone' as 'reader,' and using the webContentLink value for the file as the published URL. Also in this case, if I go to the link when not signed in to Google Apps, I am redirected to sign-in.
I call the following method to set permissions using this:
thePermission = insert_permission(userNickName,file['id'],"me","anyone","reader")
the 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 UI interface primarily in this question, as it seems simpler to find out if I am expecting the correct result using what Google has made.