Sharepoint Online 365 OAuth Setup
  • 01 May 2025
  • 1 Minute to read
  • Dark
    Light

Sharepoint Online 365 OAuth Setup

  • Dark
    Light

Article summary

Overview

The following document will cover the steps required to set up and integrate with Sharepoint Online 365 using OAuth. Currently, there are two valid methods to generate OAuth tokens needed to establish a connection, using the Add-In Method, and only using Sharepoint Azure AD App method.

Prerequisites

AzureAD App Creation

To fully integrate with Sharepoint, an application in AzureAD will need to be created. This will also be used to retrieve the client secret and client ID.

  1. Open the Azure Portal
  2. Navigate to App Registration and create a new web application
  3. Copy the Application (client) ID and Directory (tenant) ID from the app's Overview page.
  4. Register as an Enterprise Application
  5. Navigate to AzureAD App - Authentication
  6. Set the Scope for the application

Retrieving Client Secret

  1. Open the Azure Portal
  2. Navigate to Microsoft Entra ID
  3. Navigate to App registrations
  4. Select the desired Application 
  5. Navigate to Certificates & Secrets
  6. Copy the Secret "Value"

Generating OAuth Tokens

Using Add-In Method

This method uses OAuth 2.0 to obtain an access token for a server-side component of the add-in to interact with a remote service.

Oauth Provider Endpoints

EndpointExample Value
Token Request URLhttps://login.microsoftonline.com/{tenant ID}/oauth2/v2.0/token
Token Refresh URLOptional
Authorize URLhttps://login.microsoftonline.com/{tenant ID}/oauth2/v2.0/authorize
Callback URL

v7/v8/v9: "https://[BasePortalURL]/HandleTokenResponse”

v7/v8/v9: "https://[BasePortalURL]:[PortNumberIfIInstalledOnAltPort] /HandleTokenResponse”

v6: "https://[BasePortalURL]/HandleTokenResponse.aspx”

Default Consumer KeyAzure App Client ID
Default Consumer Key Secret

Azure App Client Secret VALUE


Oauth Provider Endpoints (Classic Sharepoint)

Classic SharePoint Add-Ins Support
Classic SharePoint Add-Ins are supported in Sharepoint Online until April 2, 2026, after which they will be retired. New Add-Ins cannot be submitted or installed. For modern development, use Sharepoint Framework (SPFx) and Azure AD apps. On-premises SharePoint still supports Add-Ins.
EndpointExample Value
Token Request URLhttps://accounts.accesscontrol.windows.net/[Tenant ID]/tokens/OAuth/2
Token Refresh URLOptional
Authorize URLhttps://[Tenant Name].sharepoint.com/_layouts/OAuthAuthorize.aspx
Callback URL

https://[BasePortalURL]/HandleTokenResponse

https://[BasePortalURL]:[PortNumberIfIInstalledOnAltPort]/HandleTokenResponse

Consumer KeyThe default consumer key will be [Sharepoint Add In ClientID]@[TenantID]


Using Sharepoint Azure AD App Only

EndpointExample Value
Token Request URLhttps://login.microsoftonline.com/{tenant ID}/oauth2/v2.0/token
Token Refresh URLOptional
Authorize URLhttps://login.microsoftonline.com/{tenant ID}/oauth2/v2.0/authorize
Callback URL

v7/v8/v9: "https://[BasePortalURL]/HandleTokenResponse”

v7/v8/v9: "https://[BasePortalURL]:[PortNumberIfIInstalledOnAltPort] /HandleTokenResponse”

v6: "https://[BasePortalURL]/HandleTokenResponse.aspx”

Default Consumer KeyAzure App Client ID
Default Consumer Key Secrect

Azure App Client Secret VALUE


OAuth Provider Endpoints (Classic Sharepoint)

EndpointExample Endpoint
Token Request URLhttps://accounts.accesscontrol.windows.net/[Tenant ID]/tokens/OAuth/2
Token Refresh URLOptional
Authorize URLhttps://[Tenant Name].sharepoint.com/_layouts/OAuthAuthorize.aspx
Callback URL

https://[BasePortalURL]/HandleTokenResponse

https://[BasePortalURL]:[PortNumberIfIInstalledOnAltPort]/HandleTokenResponse

The Default Consumer Key will be 00000003-0000-0ff1-ce00-000000000000/[TenantName].sharepoint.com@[TenantID]


Sharepoint Limitations

Sharepoint has inherent limitations in its capacity to handle files. They are:

  • Only 5,000 files can be displayed in a view.
  • Only 300,000 files can be in a library before there are performance issues.
  • Unique document permissions are limited to 50,000 items per list.

Was this article helpful?