AI & Agents

How to Get a SharePoint API Key: Authentication and App Registration

SharePoint does not issue traditional static API keys; programmatic access requires Microsoft Entra ID App Registration, OAuth 2.0 client credentials, and scoped Microsoft Graph permissions. Developers building automation scripts or agent connectors often face permission hurdles and tenant consent requirements. This guide covers registering an Entra ID application, generating client credentials, managing permission boundaries, and connecting AI agents to SharePoint document libraries.

Tom Langridge 15 min read Updated
SharePoint authenticates programmatic requests through Microsoft Entra ID app registrations and OAuth tokens rather than static API keys.

Why SharePoint Has No Static API Key and What to Use Instead

When developers set out to connect a custom script, an ETL pipeline, or an AI agent to SharePoint, they usually search for a single alphanumeric string called an API key. They expect a bearer credential identical to what they receive from OpenAI, Stripe, or AWS. That search always fails because SharePoint does not issue static API keys. Instead, Microsoft delegates all programmatic access to Microsoft Entra ID through OAuth 2.0 app registrations, client secrets, cryptographic certificates, and scoped permission manifests.

SharePoint does not issue traditional static API keys; programmatic access requires Microsoft Entra ID App Registration, OAuth 2.0 client credentials, and scoped Microsoft Graph permissions. In an enterprise Microsoft 365 tenant, security administrators deliberately restrict application registration and consent to prevent untracked data exfiltration. Unlike consumer cloud storage services where a personal access token can expose an entire folder tree, SharePoint permissions bind directly to corporate directory policies, conditional access rules, and explicit administrative consent gates.

To authenticate against SharePoint Online programmatically, you must complete four core setup phases in the Microsoft Entra admin center:

  1. Register an application within your Entra ID tenant to obtain an Application (client) ID and a Directory (tenant) ID.
  2. Generate a client secret or upload a public certificate under Certificates & secrets.
  3. Assign Microsoft Graph or SharePoint permissions (Sites.Read.All, Sites.ReadWrite.All, or site-scoped Sites.Selected).
  4. Obtain tenant administrative consent to approve the permission scopes for your organization.

Developers searching for 'sharepoint api key' are typically building automation scripts or AI agent connectors and lack Azure tenant admin rights. When an unprivileged user creates an application registration, they can generate client credentials, but they cannot grant the application-level permissions required for headless background execution. Understanding how Entra ID structures these credentials prevents wasted hours debugging authorization failures.

The Retirement of Legacy Azure ACS and AppRegNew

Many legacy tutorials and discussion threads instruct developers to navigate to a hidden URL inside their SharePoint site collection: /_layouts/15/appregnew.aspx and /_layouts/15/appinv.aspx. Historically, this page allowed site administrators to generate a client ID and client secret using Azure Access Control Service (ACS) without opening the Azure portal.

Microsoft permanently retired Azure ACS for SharePoint Online on April 2, 2026. Any application principals, legacy add-ins, or automation scripts created through appregnew.aspx ceased functioning after that cutoff. New SharePoint Online tenants created after late 2023 already blocked ACS by default. Attempting to use ACS endpoints today results in immediate authentication rejection.

Modern integrations must use Microsoft Entra ID app registrations. The modern framework replaces legacy XML permission requests with OAuth 2.0 token issuance, supports certificate-based authentication, and allows tenant administrators to audit and revoke application tokens through unified security dashboards.

Step-by-Step Entra ID App Registration and Credential Setup

Creating credentials for SharePoint Online requires administrative or developer access to the Microsoft Entra admin center. The following procedure walks through registering an application, generating a client secret, configuring scopes, and acquiring an OAuth 2.0 access token.

Step 1: Register an Application in Microsoft Entra ID

  1. Open the Microsoft Entra admin center and sign in with your Microsoft 365 administrative or developer account.
  2. In the left navigation menu, expand Identity, expand Applications, and select App registrations.
  3. Select New registration at the top of the pane.
  4. Enter an application name, such as SharePoint-Automation-Connector.
  5. Under Supported account types, select Accounts in this organizational directory only (Single tenant).
  6. Leave the Redirect URI blank unless you plan to use interactive user sign-in flows. For background scripts and headless daemons, no redirect URI is required.
  7. Select Register.

Once created, the portal displays the application overview page. Copy the Application (client) ID and the Directory (tenant) ID into a secure configuration store. You need both values to request access tokens.

Step 2: Generate an Application Client Secret

  1. Under the application menu on the left, select Certificates & secrets.
  2. Select the Client secrets tab, then select New client secret.
  3. Enter a description (such as Production Script Key) and choose an expiration window. Microsoft recommends 180 days (6 months) to enforce routine credential rotation.
  4. Select Add.
  5. Immediately copy the string in the Value column. This string acts as your application password. Once you leave this page, Entra ID masks the secret permanently. If you lose it, you must generate a new one.

Step 3: Add API Permissions

  1. Select API permissions from the left menu.
  2. Select Add a permission, then select Microsoft Graph.
  3. Choose your permission type based on your integration model:
    • Select Application permissions if your code runs as a background script, scheduled job, or headless AI agent without human interaction.
    • Select Delegated permissions if your application signs in a human user and acts on their behalf.
  4. Search for Sites and select the appropriate scope:
    • Sites.Read.All: Grants read permissions across all SharePoint site collections in the tenant.
    • Sites.ReadWrite.All: Grants read and write permissions across all site collections.
    • Sites.Selected: Limits the application to explicitly designated site collections rather than granting tenant-wide access.
  5. Select Add permissions.

Under API permissions, observe the status column next to your configured scopes. For application permissions, the portal displays a warning stating Not granted for <Organization>.

  1. A user holding the Global Administrator, Privileged Role Administrator, or Cloud Application Administrator role must select Grant admin consent for .
  2. Select Yes in the confirmation prompt.
  3. Verify that a green checkmark appears indicating that consent is granted for the tenant.

Requesting an OAuth 2.0 Access Token via HTTP

With your tenant ID, client ID, and client secret in hand, your code can request a bearer access token from the Microsoft identity platform. The token endpoint uses standard OAuth 2.0 client credentials grant mechanics.

Submit an HTTP POST request to the token issuance endpoint:

curl -X POST "https://login.microsoftonline.com/<your-tenant-id>/oauth2/v2.0/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "client_id=<your-client-id>" \
  -d "client_secret=<your-client-secret>" \
  -d "scope=https://graph.microsoft.com/.default" \
  -d "grant_type=client_credentials"

The identity platform responds with a JSON payload containing your temporary access token:

{
  "token_type": "Bearer",
  "expires_in": 3599,
  "ext_expires_in": 3599,
  "access_token": "<your-access-token>"
}

The access_token string is a signed JSON Web Token. You must include this string in the Authorization header of all subsequent API calls to Microsoft Graph:

curl -X GET "https://graph.microsoft.com/v1.0/sites/<your-tenant>.sharepoint.com:/sites/<site-name>:/drives" \
  -H "Authorization: Bearer <your-access-token>"

Access tokens expire after 3600 seconds (one hour). Production scripts must implement logic to track the token expiration timestamp and request a fresh token before invoking subsequent endpoints.

Comparing Delegated Permissions and Application Client Credentials Grants

Competitor tutorials frequently overlook the operational difference between delegated user permissions and application client credentials grants. Conflating the two permission models is the primary reason automation scripts and AI agent integrations stall during enterprise review.

Delegated permissions execute within the context of a signed-in human user. When an interactive web app or desktop client requests delegated access, the user logs in through Microsoft 365 and approves consent. The resulting access token contains both the application identity and the user identity. Microsoft Graph applies security trimming: the application can only view or modify document libraries that the signed-in user already has permission to open in their web browser. If an employee cannot access an executive financial site, the delegated application cannot access it either.

Application permissions execute without any user presence. The application operates as an independent service principal. When granted Sites.Read.All as an application permission, the software possesses autonomous read authority over every SharePoint site, team document library, and personal OneDrive across the entire corporate directory.

The Security Challenge for Headless AI Agents

Autonomous AI agents, automated indexers, and nightly sync jobs run headlessly. They have no interactive human to click through an Entra ID login screen or solve an authentication prompt. As a result, developers building agentic integrations must configure Application permissions.

This requirement triggers immediate friction with enterprise IT security teams:

  • Over-privileged scope: Corporate security officers routinely reject requests for Sites.Read.All because a compromised client secret would grant an attacker visibility into payroll records, customer data, and legal correspondence.
  • Consent roadblocks: Application permissions strictly mandate tenant administrator consent. Standard developers and data science teams cannot self-grant these permissions.
  • Audit complexity: Actions taken under an application permission register under the service principal name rather than an individual human, making individual accountability harder to reconstruct without specialized log parsing.

Restricting Access with Sites.Selected and the Direct REST API Trap

To avoid granting tenant-wide read access to a headless script, Microsoft provides the Sites.Selected permission scope. Under this model, an Entra ID application receives no inherent access to any site collection upon initial registration. Instead, a SharePoint administrator uses PowerShell or Microsoft Graph to assign permissions to the application on specific site collections:

POST https://graph.microsoft.com/v1.0/sites/{site-id}/permissions
Content-Type: application/json
Authorization: Bearer <your-access-token>

{
  "roles": ["read"],
  "grantedToIdentities": [
    {
      "application": {
        "id": "<your-client-id>",
        "displayName": "SharePoint-Automation-Connector"
      }
    }
  ]
}

This scoped approach satisfies enterprise security teams by isolating the script to a single document library.

However, developers attempting to call the direct SharePoint REST API (https://<tenant>.sharepoint.com/_api/web) face another trap: the Unsupported app-only token error. When an application attempts to query the legacy SharePoint REST endpoint using a client secret token, SharePoint Online rejects the request. For direct SharePoint REST calls, Microsoft requires certificate-based authentication using an uploaded X.509 certificate rather than a client secret.

To use standard client secret credentials without managing public-key cryptography infrastructure, developers should target Microsoft Graph endpoints (https://graph.microsoft.com/v1.0/sites/) rather than the older SharePoint REST paths.

Connecting AI Agents to SharePoint: Native Graph Connectors vs Intelligent Workspaces

Teams deploying AI agent architectures typically maintain existing file storage in SharePoint, OneDrive, Google Drive, Box, or Dropbox. When connecting language models and autonomous agents to these repositories, engineers encounter sharp operational tradeoffs between direct Graph API integration and intelligent workspace middleware.

Building a custom agent connector on raw Microsoft Graph requires maintaining custom pagination loops, handling token refreshes every hour, and parsing complex multipart JSON payloads. Furthermore, Microsoft Graph enforces aggressive throttling policies. When an agent attempts to scan large document libraries or read document contents for retrieval-augmented generation, Graph endpoints respond with HTTP 429 (Too Many Requests) and force the agent to sleep using exponential backoff.

More critically, pulling entire folders over Microsoft Graph to supply context to an LLM inflates token consumption and degrades agent response latency. Feeding dozens of raw Office files into an agent prompt wastes context window capacity on metadata boilerplate and layout markup.

The Fast.io Path: Syncing SharePoint to Intelligent Workspaces

Fastio workspaces allow teams to sync SharePoint folders and connect AI agents using standard API tokens and remote MCP. Rather than wrestling with Entra ID app registrations, tenant consent, and Graph token lifecycles, teams can bridge their existing SharePoint document libraries into a dedicated, intelligent workspace designed for storage for AI agents.

In this architecture, your team keeps their existing storage inside SharePoint. Document libraries sync into a Fastio workspace through the OneDrive connector. Cloud Sync supports one-way or two-way synchronization on a schedule or on demand (never continuous, live, or real-time; Google Drive, Dropbox, Box, and OneDrive sync).

Once files sync into the workspace, Fast.io's Intelligence Mode automatically parses and indexes the documents for hybrid search combining full-text, semantic, and metadata extraction. Instead of pulling whole folders across Graph, the AI agent connects to the Fastio remote MCP server and queries indexed knowledge through semantic search.

Connector performance comparisons are published at the Fast.io benchmarks report, where Fastio was measured the fastest and the lowest cost of the providers tested.

Connecting AI Agents via Remote MCP

Connecting an AI agent to a Fastio workspace requires no Entra ID app registration or Azure tenant admin rights. AI agents connect to the remote Fast.io MCP server over Streamable HTTP:

  • Claude apps and general agents connect to https://mcp.fast.io/mcp/tools using OAuth in the browser.
  • Coding agents in an IDE, terminal, or cloud environment (such as Claude Code, Cursor, Cline, or Gemini CLI) connect to https://mcp.fast.io/mcp/code.
  • Headless agents, scheduled scripts, and framework workers send a standard scoped API key as Authorization: Bearer <your-fastio-api-key> on the connection.

For complete client configuration steps, consult the Fast.io MCP setup guide or inspect the machine-readable MCP reference. With remote MCP, the agent issues semantic search queries against the indexed SharePoint files, receiving concise, citation-backed context passages instead of draining API quotas on raw file downloads.

Fastio features

Connect AI agents to SharePoint document libraries

Sync SharePoint files into intelligent Fast.io workspaces and give agents instant MCP access with built-in semantic search. Monthly plans start with a 14-day free trial, which requires a credit card. Plans are Starter at $9.99/mo, Business at $49.99/mo, and Enterprise at $199.99/mo.

Token Lifecycle Management, Access Control, and Workspace Governance

Whether you query SharePoint through direct Microsoft Graph API calls or sync files to an intelligent workspace for agent access, maintaining data governance requires strict credential hygiene and least-privilege boundary design.

1. Enforce Credential Lifecycle Management

Client secrets generated in Microsoft Entra ID should never have indefinite validity. Best practices include:

  • Short Lifespans: Limit client secret validity to 180 days (6 months) or 365 days maximum.
  • Rotation Schedules: Generate a secondary client secret 30 days before expiration, update your deployment environments, verify successful authentication, and delete the retired secret.
  • Environment Isolation: Never store raw client secrets in code repositories. Load secrets through runtime environment variables or managed key vaults. When documenting examples or configuring configuration templates, always use clear placeholder strings like <your-client-secret>.

2. Establish Granular Workspace Boundaries

Direct Microsoft Graph application permissions grant broad access that exposes files across entire site collections. In contrast, bridging SharePoint libraries into dedicated workspaces enables granular permissions at the organization, workspace, and share level.

This isolation ensures that an AI agent assigned to analyze product documentation only has read access to the technical documentation workspace, preventing accidental retrieval of confidential human resources records or executive correspondence stored in adjacent SharePoint libraries.

3. Maintain Accountability with Activity Logs and Version History

Autonomous agents can generate high-volume write, edit, and update requests. Without a detailed activity log, tracking modifications or diagnosing corrupted files becomes impossible.

Fast.io provides a detailed activity log that records actions taken by people and agents alike, documenting uploads, edits, moves, and deletions. In addition, per-file version history preserves every iteration of a document. If an agent overwrites a collaborative document or applies flawed automated edits, team members can review the activity log and restore prior versions with a single click.

4. Transitioning Ownership Between Agents and Humans

In advanced automated environments, an AI agent can create organizations, configure project workspaces, and populate folders with extracted data. Fast.io supports ownership transfer, allowing an agent to hand administrative control of an organization or workspace to a human supervisor while retaining scoped agent access for continued maintenance.

Sources

References used to verify factual claims in this guide.

  1. Third-party integration guides note that obtaining SharePoint credentials requires creating an application with a client ID and secret.

Frequently Asked Questions

Does SharePoint have an API key?

No, SharePoint does not issue traditional static API keys. Programmatic access to SharePoint Online requires authentication through Microsoft Entra ID using OAuth 2.0. Applications must register in Entra ID, acquire credentials in the form of a client secret or public-key certificate, configure Microsoft Graph or SharePoint permissions, and request a temporary bearer access token.

How do I authenticate with the SharePoint REST API?

To authenticate with the SharePoint REST API, you register an application in the Microsoft Entra admin center. Interactive applications obtain delegated tokens through the OAuth 2.0 authorization code flow. For unattended scripts and headless background processes, Microsoft requires certificate-based authentication for direct SharePoint REST endpoints, or you can use standard client secrets with the Microsoft Graph API.

How do I connect an AI agent to SharePoint without tenant admin approval?

Tenant-wide application permissions like Sites.Read.All strictly require Azure tenant admin consent. If you lack admin rights, you cannot grant application permissions. Instead, teams can sync specific SharePoint document libraries into a Fast.io workspace using the OneDrive connector. Once synced, you connect your AI agent using a standard Fast.io API key or remote MCP server without needing Azure directory consent gates.

What happened to appregnew.aspx for SharePoint credentials?

The appregnew.aspx and appinv.aspx pages were part of Microsoft's legacy Azure Access Control Service (ACS) framework. Microsoft permanently retired Azure ACS for SharePoint Online on April 2, 2026. Any credentials or add-ins generated through these pages no longer function. Modern integrations must use Microsoft Entra ID app registrations.

Why does my SharePoint REST API call fail with an unsupported app-only token error?

Direct SharePoint Online REST endpoints reject app-only access tokens acquired using standard client secrets. For direct REST calls without a signed-in user, Microsoft requires certificate-based authentication using an uploaded X.509 certificate. To use client secrets for headless automation without certificates, route your requests through the Microsoft Graph API (/v1.0/sites/) instead.

Related Resources

Fastio features

Connect AI agents to SharePoint document libraries

Sync SharePoint files into intelligent Fast.io workspaces and give agents instant MCP access with built-in semantic search. Monthly plans start with a 14-day free trial, which requires a credit card. Plans are Starter at $9.99/mo, Business at $49.99/mo, and Enterprise at $199.99/mo.