Azure AI Search Indexer scheduled execution throws error Verification code expired before contacting the server #134
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
This typically points to an OAuth token or client secret issue in the Azure App Registration used to authenticate with SharePoint. Problem Summary
I would suspect the Root Cause is one of the following
Fix
Useful resources
|
Beta Was this translation helpful? Give feedback.
-
Hi @leestott , Thanks for your message.
I have explained my actions in detail below.
![]() ![]() JSON INdexer Datasource JSON {
![]()
![]() I created new App registrationwith API permissions of type "Application". ![]() ![]() New Idexer JSON ![]() New Datasource JSON |
Beta Was this translation helpful? Give feedback.
-
Issue fixed. I will share complete steps here what I did to resolve it. |
Beta Was this translation helpful? Give feedback.
-
Thanks @leestott I was able to resolve my issue by going through this article So my issue was that my indexer on scheduled execution was continuously giving error “Verification code expired before contacting the server”.I found two reasons for this issue.1. One Indexer has limitation that when sharepoint is used as datasource then API permissions in App registration is recommended to be Application Type. “User-delegated permissions enforce token expiration every 75 minutes, per the most recent security libraries used to implement this authentication type. This isn't a behavior that can be adjusted. An expired token requires manual indexing using Run Indexer (preview). For this reason, you should use app-based permissions instead.” 2. 2ndly, When you create the indexer for the first time, the [Create Indexer (preview)] request waits until you complete the next step. You must call [Get Indexer Status] to get the link and enter your new device code. My Implementation details step by step:
How to Create a Microsoft Entra application registration
Connection string format 4. As mentioned above I need to do device login. Steps below. https://yoursearchapiurl.search.windows.net/indexers/sharepoint-indexertester/status?api-version=2025-05-01-preview&Content-Type=application/json 4.2. Follow the steps mentioned under heading in below article. Step 6: Create an indexer (Steps 3 to 7). 4.3. If you are getting error “Sign-in was successful but you don't have permission to this resource” then exclude your user from this policy for time being. ![]() After these steps, Indexer created successfully and now I am able to run it manually from portal as well as schedule is also working without any issues. ![]() Snippet of my C# code below:internal static async Task SetupAndRunIndexer(Configuration configuration, SearchIndexClient indexClient, SearchIndexerClient indexerClient, OpenAIClient openAIClient) SearchIndexerDataContainer(configuration.BlobContainerName));
} JSON Index{ JSON Indexer{ JSON Datasource. |
Beta Was this translation helpful? Give feedback.
Thanks @leestott I was able to resolve my issue by going through this article
https://learn.microsoft.com/en-us/azure/search/search-howto-index-sharepoint-online
So my issue was that my indexer on scheduled execution was continuously giving error “Verification code expired before contacting the server”.
I found two reasons for this issue.
1. One Indexer has limitation that when sharepoint is used as datasource then API permissions in App registration is recommended to be Application Type.
“User-delegated permissions enforce token expiration every 75 minutes, per the most recent security libraries used to implement this authentication type. This isn't a behavior that can be adjusted. An ex…