Insufficient permissions for this file, unable to share link, 403

有些话、适合烂在心里 提交于 2021-02-11 06:56:38

问题


// ... role=reader, type=anyone, with_link=true .... $perms
$service->permissions->insert($fileId, $perm); // see error below
HTTP Code: 403
[
   {
      "domain": "global",
      "reason": "forbidden",
      "message": "Insufficient permissions for this file",
      "locationType": "other",
      "location": "file.permissions"
   }
]

Users of a specific domain are unable to share links. The error above is not listed here https://developers.google.com/drive/v2/web/handle-errors

The admin of the domain is certain that "share with public" is allowed for all users of their domain.


回答1:


You may need to check if you set the scopes right for the users in order for them to access the file. See Authorizing requests with OAuth 2.0. The scopes are the one giving permissions to certain users on what they can do to a file or folder. See What scope or scopes does my app need?

As a general rule, choose the most restrictive scope possible, and avoid requesting scopes that your app does not actually need. Users more readily grant access to limited, clearly described scopes. Conversely, users may hesitate to grant broad access to their files unless they truly trust your app and understand why it needs the information.

You may also want to see Perform Google Apps Domain-Wide Delegation of Authority. It is suggested here that you use a service account which will enable users to access your Google API through your web application.



来源:https://stackoverflow.com/questions/35095459/insufficient-permissions-for-this-file-unable-to-share-link-403

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!