0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azureサービスプリンシパルのsites.selectedではSharePointのsearchエンドポイントは叩けない

Posted at

事象

Microsoft Graph と SharePoint Online のリソース固有の同意について | Microsoft Learn

AzureサービスプリンシパルでMicrosoft Graphの Sites.Selected を付与しつつ、アクセスしたいSharePointサイト側からもサービスプリンシパルに対して読み込み or 書き込み権限を与えることで特定のSharePointサイトのみの権限に絞ることができます。

image.png

しかし、「ファイルを検索する」エンドポイントをGraphから叩いてみるとエラーになりました。

ファイルを検索する - Microsoft Graph v1.0 | Microsoft Learn

/search(q='{search-text}') は使えない

「ファイルを検索する」エンドポイントの /search(q='{search-text}')Sites.Selected だけだと権限が不足しているようで失敗するようでした。
どうしてもこれを使いたいときはより強い権限の Files.Read.All などが必要なようです。
Files.Read.All は組織のすべてのSharePointファイルを閲覧できてしまうため使いたくない)

今回は探したいファイルがある程度どこにあるか分かっていたので、 root:/...:/children: パスを使ってファイルを探すことで解決しました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?