概要
[自分メモ]
Google Drive を Ubuntuで参照したい。
個人使用目的
※一般公開OAuthアプリは要審査
環境
- Windows 11
- wsl: 2.5.7.0
- Ubuntu: 24.04.1 LTS
クライアント導入
sudo add-apt-repository ppa:alessandro-strada/ppa
sudo apt update
sudo apt install -y google-drive-ocamlfuse
Google Driveの設定
- Google Drive API設定ページ
- APIを有効にする [MANAGE(管理)]
- [APIとサービス] > [OAuth consent screen(同意画面)] > [Clients(クライアント)] > クライアント新規作成 > "デスクトップアプリ"を追加
- Client ID と Client secret を採取
- [Audience(対象)] > [Test user] > 利用者(自分)のgmailアドレス追加
使用
認証とマウント
GOOGLEDRIVE_CLIENT_ID=xxxxxxxxxx.apps.googleusercontent.com
GOOGLEDRIVE_SECRET=XXX-YYY-ZZZ
mkdir ~/gdrive
google-drive-ocamlfuse -id $GOOGLEDRIVE_CLIENT_ID -secret $GOOGLEDRIVE_SECRET ~/gdrive
未認証の場合ブラウザが開く。認証後、ブラウザクローズ。 GUIがない場合は -headless
オプションをつける
確認
mount | grep google-drive-ocamlfuse
# こんな感じで表示されたらOK
# google-drive-ocamlfuse on /home/shokkaa/gdrive type fuse.google-drive-ocamlfuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
参考