Google API - DocumentList - 创建共享链接

发布于 2024-12-04 23:48:22 字数 969 浏览 0 评论 0原文

使用文档列表 API v3.0,我已经创建了一个文档。但现在我想使用共享链接私下共享它。

协议指南表明我应该构建一个像这样的 POST 请求:

POST /feeds/default/private/full/<resource_id>/acl
GData-Version: 3.0
Authorization: OAuth <access_token>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl='http://schemas.google.com/acl/2007'>
  <category scheme='http://schemas.google.com/g/2005#kind'
    term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='user' value='[email protected]'/>
</entry>

但我的范围有问题。指南列出了其中 4 个:

  • user — 用户的电子邮件地址。 =>我想要一个链接,我什至不知道在流程结束时访问该文档的人的电子邮件地址。
  • 群组 — Google 群组电子邮件地址。 =>我没有使用组。
  • 域 — Google Apps 域。 =>我没有使用任何域。
  • 默认 — 与所有用户公开共享。 =>我不希望该文件被公开。

那么我应该使用什么范围才能通过共享链接访问私人文档?

Using the Document List API v3.0, I'm already creating a document. But now I want to share it privately using a shared link.

The protocol guide indicate that I should build a POST request like this one:

POST /feeds/default/private/full/<resource_id>/acl
GData-Version: 3.0
Authorization: OAuth <access_token>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl='http://schemas.google.com/acl/2007'>
  <category scheme='http://schemas.google.com/g/2005#kind'
    term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='user' value='[email protected]'/>
</entry>

But I have a problem with the Scope. The guide list 4 of them:

  • user — a user's email address. => I want a link, I don't even know the email address of the person who'll access the document at the end of the process.
  • group — a Google Group email address. => I use no group.
  • domain — a Google Apps domain. => I use no domain.
  • default — publicly shared with all users. => I don't want the document to be public.

So what scope should I use to have a private document accessible with a sharing link ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

居里长安 2024-12-11 23:48:22

据我所知,我需要使用默认范围,然后将角色限制为特定键。

POST /feeds/default/private/full/<resource_id>/acl
GData-Version: 3.0
Authorization: OAuth <access_token>

<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'>
<category scheme='http://schemas.google.com/g/2005#kind'
 term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:withKey key='dummy_key'>
     <gAcl:role value='writer'/>
  </gAcl:withKey>
  <gAcl:scope type='default'/>
</entry>

Google API 文档根本没有解释应该放在关键属性中。但好消息是,我只是输入了一个随机字符串,并且该文件似乎可以通过共享链接访问,而无需全体公众访问。

现在可以通过以下 URL 访问该文档:

https://docs.google.com/document/d/<untyped_ressource_id>/edit?hl=en_GB

对于记录,如果我想让公众可以访问该文档(引用等),我只需删除 withKey 部分即可:

POST /feeds/default/private/full/<resource_id>/acl
GData-Version: 3.0
Authorization: OAuth <access_token>

<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'>
<category scheme='http://schemas.google.com/g/2005#kind'
 term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='default'/>
</entry>

From what I've understood yet, I need to use the default scope, and then restrict the role to a specific key.

POST /feeds/default/private/full/<resource_id>/acl
GData-Version: 3.0
Authorization: OAuth <access_token>

<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'>
<category scheme='http://schemas.google.com/g/2005#kind'
 term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:withKey key='dummy_key'>
     <gAcl:role value='writer'/>
  </gAcl:withKey>
  <gAcl:scope type='default'/>
</entry>

The Google API Documentation doesn't explain at all what's supposed to go in the key attribute. But the good news is that I just put a random string and the file apear to be accessible with the shared link, without beeing accessible to the whole public.

The document is now accessible with the following URL:

https://docs.google.com/document/d/<untyped_ressource_id>/edit?hl=en_GB

For the reccord, if I wanted to have the document accessible to the public ( referenced, etc. ) I would simply remove the withKey Part:

POST /feeds/default/private/full/<resource_id>/acl
GData-Version: 3.0
Authorization: OAuth <access_token>

<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'>
<category scheme='http://schemas.google.com/g/2005#kind'
 term='http://schemas.google.com/acl/2007#accessRule'/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='default'/>
</entry>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文