Google Drive API V3:为域创建文件权限
Google Drive API V3: Creating file permissions for a domain
尝试通过 Google 驱动器的 API V3 和我 运行 向文件添加权限,出现以下错误。我想允许来自我的站点 mta.io 的请求能够读取该文件。该错误似乎来自我在请求正文中传递的域,例如,example.com 工作正常并且权限已被 g运行 授予。我是否需要将我的域列入白名单才能授予它对该文件的权限?
作品:
{
"role": "reader",
"type": "domain",
"domain": "example.com"
}
无效:
{
"role": "reader",
"type": "domain",
"domain": "mta.io"
}
错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "The specified domain is invalid or not applicable for the given permission type.",
"locationType": "other",
"location": "permission.domain"
}
],
"code": 400,
"message": "The specified domain is invalid or not applicable for the given permission type."
}
}
我正在使用 API 网站上的 try it 功能。
基于此,这只能在同一域中的用户之间进行,服务帐户不属于任何域。
You're best option may be to create a Team Drive that the service account has access to, and perform a two stage process:
- Use the service account to move the file into the team drive.
Files.update
with the addParents
parameter set to the Team Drive ID.
- Use the domain user to move the file out of the team drive.
Files.update
with the addParents
parameter set to root
(or some target folder's ID) and the removeParents
parameter set to the Team Drive ID.
这是另一个可能也有帮助的 SO post:Google Drive SDK - change item sharing permissions
明白了,您只能使用 G Suite 域。
这很糟糕,但为了与域独占共享文件权限,您需要拥有 G Suite 帐户并验证您拥有该域 - 该域需要与您的 G Suite 帐户相关联。
https://developers.google.com/drive/v3/web/about-permissions#types_and_values
For example, a permission with a type of domain may have a domain of thecompany.com, indicating that the permission grants the given role to all users in the G Suite domain thecompany.com
尝试通过 Google 驱动器的 API V3 和我 运行 向文件添加权限,出现以下错误。我想允许来自我的站点 mta.io 的请求能够读取该文件。该错误似乎来自我在请求正文中传递的域,例如,example.com 工作正常并且权限已被 g运行 授予。我是否需要将我的域列入白名单才能授予它对该文件的权限?
作品:
{
"role": "reader",
"type": "domain",
"domain": "example.com"
}
无效:
{
"role": "reader",
"type": "domain",
"domain": "mta.io"
}
错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "The specified domain is invalid or not applicable for the given permission type.",
"locationType": "other",
"location": "permission.domain"
}
],
"code": 400,
"message": "The specified domain is invalid or not applicable for the given permission type."
}
}
我正在使用 API 网站上的 try it 功能。
基于此
You're best option may be to create a Team Drive that the service account has access to, and perform a two stage process:
- Use the service account to move the file into the team drive.
Files.update
with theaddParents
parameter set to the Team Drive ID.- Use the domain user to move the file out of the team drive.
Files.update
with theaddParents
parameter set toroot
(or some target folder's ID) and theremoveParents
parameter set to the Team Drive ID.
这是另一个可能也有帮助的 SO post:Google Drive SDK - change item sharing permissions
明白了,您只能使用 G Suite 域。 这很糟糕,但为了与域独占共享文件权限,您需要拥有 G Suite 帐户并验证您拥有该域 - 该域需要与您的 G Suite 帐户相关联。
https://developers.google.com/drive/v3/web/about-permissions#types_and_values
For example, a permission with a type of domain may have a domain of thecompany.com, indicating that the permission grants the given role to all users in the G Suite domain thecompany.com