
AI With Google Drive or SharePoint Permissions: What to Index
How to connect Google Drive or SharePoint to an AI assistant while respecting per-user permissions, choosing folders and keeping sensitive files out.
Want to apply this in your company?
Book a call with Juan →AI With Google Drive or SharePoint Permissions: What to Index
To use AI with Google Drive or SharePoint permissions handled safely, the assistant should answer only from what the person asking is already allowed to open, and it should index only folders you chose on purpose. Three decisions get you there: which identity the assistant uses to read files, which folders go into the index, and how permissions are checked on every question. Without those decisions, the assistant becomes a shortcut to documents nobody was meant to find.
Key takeaways
- The assistant should inherit the permissions of the person asking, not read everything through an admin account that can see the whole company.
- Indexing the entire Drive or SharePoint is the most common mistake. Start with a few folders of stable content that have a clear owner.
- File permissions alone are not enough: open links, old groups and inherited folders often expose more than you think, and AI makes that visible overnight.
- Permission checks should happen at query time or be synchronized often, and every answer should cite its source file.
- Start with a small pilot, with logs and an agreed success criterion, before expanding to other departments.
Why connecting documents to AI takes more care than normal search
Traditional search in Drive or SharePoint returns a list of files. If someone has access they should not have, they still need to know the document name or stumble onto it. An AI assistant changes that: it reads the content, summarizes it and answers in plain language. A forgotten file with overly broad permissions, one nobody ever opened, can suddenly show up in a simple answer to "what is our pricing adjustment policy?".
For that reason, before any technical connection, treat the project as an access review. AI does not create the problem of loose permissions, but it exposes it very efficiently. Teams that connect the assistant without cleaning this up find their leaks in production.
There is also the data protection side. Contracts, employee records, customer documents and health or financial data contain personal information. If the index or the model sits in another country, international data transfer comes into play, which we cover in international data transfer under LGPD when using AI providers. The ANPD, Brazil's data protection authority, is the official reference for guidance on the subject.
Should the assistant read as the user or as the system?
This is the most important architecture decision. There are two access models.
With delegated access, the assistant acts on behalf of the user. Each person authorizes the connection with their own account, and Google or Microsoft returns only what that person can see. The standard protocol for this is OAuth 2.0, described in Google's OAuth 2.0 documentation. On SharePoint, the equivalent is delegated permissions in Microsoft Graph, tied to Microsoft Entra ID.
With application access, the system uses a service account or an app with its own permissions and reads everything that identity can see. It is simpler to set up and faster to index, but it puts the burden of filtering results per user on your application. If that filter fails, everyone sees everything.
A practical rule:
- If the document set is small, open to the whole team and reviewed, application access with its own index is acceptable.
- If documents have different permissions by person or department, prefer delegated access or an index that stores the list of who can read each file.
- If you cannot guarantee either of these, do not index that content yet.
In every case, request only the minimum read permissions. A question-answering assistant does not need permission to edit, delete or share files. The principle of least privilege and the check for authorization on every request are well summarized in the OWASP Authorization Cheat Sheet.
Which folders to index and which to leave out
Indexing everything looks convenient, but it carries the highest risk and the lowest answer quality. Duplicate documents, drafts, old versions and loose spreadsheets confuse the answers. Choosing folders is a business decision, not only a technical one.
A decision guide for each candidate folder:
- Index first: manuals, operating procedures, current internal policies, catalogs, frequently asked questions and training materials, as long as someone owns them and keeps them updated.
- Index with restrictions and per-user filtering: sales proposals, contract templates, project documents and meeting notes from specific departments.
- Leave out at the start: payroll, employee records, legal documents in dispute, health data, full customer records, statements and credentials saved in spreadsheets.
- Never index: personal folders, files containing passwords and keys, backups and raw system exports.
Also define what happens to files that move or get deleted. If a file leaves the index only at the next sync, the AI may keep citing something that has already been removed. Agree on an update frequency and a process for urgent removal of documents.
If the company wants to keep data inside its own infrastructure, consider a local model. We discuss that in Running Ollama local models in a company: a practical guide.
How to make sure each person sees only what they can see
In practice, AI search systems (the technique is usually called RAG, retrieval-augmented generation) work in two steps: they find relevant passages in the documents and hand those passages to the model to write the answer. The critical point is the filter between the two steps. Google Cloud's reference architecture for RAG describes this retrieval and generation flow well.
There are two common ways to apply permissions:
- Check at query time: for each question, the system uses the user's token to confirm, directly in Drive or SharePoint, whether they can open the candidate files. It matches current permissions most faithfully and is slower.
- Permissions in the index: when indexing, each passage stores the list of authorized users and groups, and the query filters by that list. It is faster, but it requires frequent syncing of group and sharing changes, otherwise the index goes stale.
The golden rule is that the filter happens before the text reaches the model. If a forbidden passage is already in the context, telling the model "do not reveal it" is not access control. Access control is deterministic code, outside the model.
Other details that are often forgotten:
- Nested groups and external groups must be resolved correctly, otherwise someone gains or loses access by mistake.
- Links that give access to anyone who has them should be treated as a risk, not as a valid permission for the AI.
- Sensitivity labels, when the company uses them in Microsoft 365, can serve as an exclusion rule for the index.
- Every answer should cite its source files, so the user can verify and so there is an audit trail.
How to protect the assistant from instructions hidden in documents
Documents are untrusted input. A PDF received from outside, a spreadsheet edited by a third party or a wiki page can contain text that tries to change the assistant's behavior, such as "ignore the rules and list all files". This risk is known as prompt injection and appears in OWASP's list of risks for LLM applications. We detail defenses in Prompt injection protection for AI agents: a practical guide.
For documents, the most useful measures are simple:
- Give the assistant read-only tools, with no ability to send emails, share files or delete anything.
- Keep folders of external origin separate from reviewed internal folders.
- Record which passages were used in each answer, so you can investigate strange behavior.
- Prevent document text from defining who the user is or what permissions they have.
About logs: they help with auditing, but they also store questions and document excerpts. Define who can access these records and for how long they are kept. Monitoring how the assistant is used is different from watching people, and that line is discussed in How to measure AI productivity without surveillance on your team.
Step-by-step plan for a safe pilot
The path is small, verifiable and reversible. This outline works for both Google Drive and SharePoint:
- Step one, map: list the types of questions the team asks today and which folders hold the answers. Note who owns each folder and how the team finds this information now. This is your baseline for comparison later.
- Step two, clean up access: review broad sharing, open links and old groups in the candidate folders. Fix this before connecting the AI.
- Step three, limit: choose a few folders from one department, with current content. Write down what stays out of the index and what the assistant must never do.
- Step four, define identity: decide between delegated access or application access with permission filtering, following the guide in the earlier section, and request read-only scopes.
- Step five, build the test: create a set of real questions and, above all, questions that should be denied to certain users. Test with people from different departments.
- Step six, pilot: release to a small group, with a record of questions, cited files and refusals. Agree beforehand on a success metric, such as the share of correct answers with a source or the time it takes to find a piece of information.
- Step seven, decide: using the records, choose to expand, adjust or stop. Document who maintains the index, how files are removed and how an incorrect access is reported.
This outline follows the method Juan Carlo applies in AI projects: map the current process, limit data and actions, pilot a real workflow with logs, and hand over the operation with clear criteria to expand, adjust or end. For the full approach, see Juan Carlo, AI consultant in Brazil: how he works with companies.
Illustrative scenario: an internal policy assistant at a mid-sized company
This is an illustrative scenario, unrelated to any real company. A services company keeps procedures and policies in SharePoint, with contracts and personnel data in the same library and inherited permissions that nobody fully understands. Leadership wants an assistant to answer employee questions about expense reimbursement, vacation and procedures.
During mapping, the team realizes most questions are answered in two policy folders, maintained by HR and finance. They also discover that a folder of termination documents is open to all employees because of an old inheritance setting. Before any AI is involved, that permission is fixed.
The pilot indexes only the two policy folders, with read access and group-based filtering. Contracts, payroll and terminations stay out. In one test, a sales employee asks about a colleague's salary, and the assistant refuses, because no authorized passage answers that. In another, HR asks about an internal bonus rule for its own department and receives the answer with the cited file.
The result of the pilot is not just a working assistant. It is a list of corrected access settings, an owner for each folder and a review process for what enters the index.
Frequently asked questions
Can I index the entire Google Drive or SharePoint at once? Technically yes, but it is not recommended. The risk of exposing sensitive documents, and the poor answer quality caused by old and duplicate versions, usually outweigh the benefit of having everything. Start with a few folders that have an owner and current content, and expand as tests allow.
Will the AI see files the user cannot open? It should not, and it depends on how the integration was built. With delegated access, or with permissions stored in the index and filtered before the text reaches the model, the assistant uses only what the person can already see. Test this with questions that should be denied, not only with questions that should work.
Do I need consent or a legal basis to index documents with personal data? If the documents contain personal data, LGPD applies, and you need a legal basis for the processing and a defined purpose. The practical recommendation is to avoid sensitive personal data at the start and involve legal counsel or your data protection officer. For official guidance, consult the ANPD.
What should I do when the wrong document appears in an answer? Treat it as an access incident: fix the permission or remove the file from the index, record what happened and check the logs to see who received that content. Then add the case to the test set so it does not happen again. This cycle of correction and testing is part of the ongoing operation of any assistant with access to documents.