Skip to content

MSSharePointFetcher - Allow specifying region as request parameter (needed when using application permissions). #3673

Description

@aleixrm

Is your feature request related to a problem? Please describe.
Currently, the MSSharePoint integration only supports Microsoft on-behalf-of OAuth workflows (using the current OAuth integration components available in Haystack). In the case you want to use app-only authentication and authorization, you need to acquire the token accessing the api directly, e.g.

import requests
token_url = f"https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token"
data = {
    "client_id": CLIENT_ID,
    "scope": "https://graph.microsoft.com/.default",
    "client_secret": CLIENT_SECRET,
    "grant_type": "client_credentials"
}
response = requests.post(token_url, data=data)
response.raise_for_status()
token = response.json().get("access_token")

but when running the pipeline using the MSSharePointRetriever setting the token, I receive the following error:

haystack Component type: 'MSSharePointRetriever'
haystack Error: Microsoft Graph search request failed with status 400: {"error":{"code":"BadRequest","message":"SearchRequest Invalid (Region is required when request with application permission.)","target":"","details":[{"code":"Microsoft.SubstrateSearch.Api.ErrorReporting.ResourceBasedExceptions.BadRequestException","message":"Region is required when request with application permission.","target":"","httpCode":400}],"httpCode":400}

Testing the API directly, I see the same error, and it only works when we add the field "region": "US" in the request body.

Describe the solution you'd like
Allowing to define the region as init parameter for the MSSharePointFetcher object and adding it to the request body.

Additional context
When not including the region in the request, the following error is thrown from the API:

  "error": {
    "code": "BadRequest",
    "message": "SearchRequest Invalid (Region is required when request with application permission.)",
    "target": "",
    "details": [
      {
        "code": "Microsoft.SubstrateSearch.Api.ErrorReporting.ResourceBasedExceptions.BadRequestException",
        "message": "Region is required when request with application permission.",
        "target": "",
        "httpCode": 400
      }
    ],
    "httpCode": 400
  },

This component is using the searchEntity API:

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions