LoginSignup
0
0

More than 1 year has passed since last update.

Google Drive API v3でthumbnailLinkが出ないとき

Posted at

きっかけ

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のフィールドが返されていたのに、ファイルの中身が見えるスコープでないと返さないようになった模様。

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