Search code examples
google-apigoogle-docs-api

Can't remove access to google doc via api when not dealing with primary google email address


Using the google document API, I am creating a document and added access rules. In my system I only have one email address of this particular user. Let's say it's johndoe@company.com. Using that email address I add an access rule to my google doc. Within google John Doe has two email addresses: a primary (johndoe@gmail.com) and a secondary (johndoe@company.com). Google seems to be smart enough to make the association and when I look at the sharing for that document it shows John's primary email address (johndoe@gmail.com).

The problem is now I need to find that access rule and delete it, so I do a find (using the document API) to find the access rule by email address and since I only have the one email address (johndoe@company.com) google returns nothing.

Hopefully I'm missing a simple solution here such as:

  • Can I request the access rule from google using the email address I have and using some undocumented feature have google look up the record via primary or secondary email address?

  • Obtain the primary email address on access rule creation? (doesn't appear to be returned).

Thanks in advance!


Solution

  • According to the API, you just need to issue a DELETE request for the give acl. See "Removing sharing permissions". So, it should resolve the primary/secondary emails for you just like add.

    https://developers.google.com/google-apps/documents-list/