きっかけ
GET https://www.googleapis.com/drive/v3/files
など、Google Drive API v3を使ってファイルの情報を取得したときに、2022年2月時点は返されるフィールドにサムネイル画像のリンク先を表すthumbnailLink
があったのに、2022年4月にはなくなっていたので解決法を確認した。
結論
スコープで少なくともファイルの中身を見ることができるdrive.readonly
以上を指定する。
参考になるドキュメント
Google Drive APIのFilesのリソースリファレンス
thumbnailLink
A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content. If the file isn't shared publicly, the URL returned in Files.thumbnailLink must be fetched using a credentialed request.
Google Drive APIのスコープ一覧
スコープ | 説明 |
---|---|
https://www.googleapis.com/auth/drive | すべてのGoogleドライブファイルを表示、編集、作成、および削除します |
https://www.googleapis.com/auth/drive.appdata | Googleドライブで独自の構成データを表示および管理する |
https://www.googleapis.com/auth/drive.file | このアプリで開いた、または作成したGoogleドライブのファイルとフォルダを表示および管理しま |
https://www.googleapis.com/auth/drive.metadata | Googleドライブ内のファイルのメタデータを表示および管理する |
https://www.googleapis.com/auth/drive.metadata.readonly | Googleドライブ内のファイルのメタデータを表示する |
https://www.googleapis.com/auth/drive.photos.readonly | Googleフォトで写真、ビデオ、アルバムを表示する |
https://www.googleapis.com/auth/drive.readonly | すべてのGoogleドライブファイルを表示してダウンロードします |
https://www.googleapis.com/auth/drive.scripts | Google AppsScriptスクリプトの動作を変更する |
2022年2月に書いたときはdrive.metadata.readonly
でもthumbnailLink
のフィールドが返されていたのに、ファイルの中身が見えるスコープでないと返さないようになった模様。