[[PageOutline]] = setup project = * [https://code.google.com/apis/console/ Google APIコンソール]を初めて開くと[https://console.developers.google.com/apis/library ライブラリ]にリダイレクトされる * https://console.developers.google.com/ からプロジェクトを作成し、必要なAPIを有効にしたうえでOAuthのクライアントIDとクライアントシークレットを作成する * 自分で作成したプロジェクトのクライアントIDを用いることで、APIの発行状況やエラー発生件数などがダッシュボードから確認できるようになる 1. 初めてダッシュボードにアクセスした際には、利用規約への同意が求められる[[br]][[Image(oauth-01.png,33%)]] [[Image(oauth-02.png,33%)]] 2. プロジェクトの新規作成[[br]][[Image(oauth-03.png,33%)]] [[Image(oauth-04.png,33%)]] 3. 使用するAPIの有効化[[br]][[Image(oauth-05.png,33%)]] [[Image(oauth-06.png,33%)]] 4. 認証情報の作成[[br]][[Image(oauth-07.png,33%)]] [[Image(oauth-08.png,33%)]] 5. OAuth認証時の同意画面に表示する情報の設定[[br]][[Image(oauth-09.png,33%)]] [[Image(oauth-10.png,33%)]] * サービス名は「My OCAMLDrive」としている 6. アプリケーションの種類は「その他」とする[[br]][[Image(oauth-11.png,33%)]] 7. クライアントIDが生成され、表示もしくはjson形式でダウンロードできるようになる[[br]][[Image(oauth-12.png,33%)]] {{{ {"installed":{"client_id":"732618592028-28no107k9v98trf6meb8eegdpvjlr53o.apps.googleusercontent.com", "project_id":"fabled-frame-162115", "auth_uri":"https://accounts.google.com/o/oauth2/auth", "token_uri":"https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs", "client_secret":"ndaIX_3FQqHssFDwUAwOZdpi", "redirect_uris":["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]}} }}} 8. このクライアントIDとシークレットを用いて認証要求を行うと、以下のように表示される[[br]][[Image(oauth-14.png,33%)]] 9. 認証後、表示されたトークンをアプリケーションに設定する[[br]][[Image(oauth-15.png,33%)]] = aur:google-drive-ocamlfuse = 1. デフォルトでは作者 {{{alessandro.strada@gmail.com}}} が用意したクライアントIDが用いられる[[br]][[Image(gdocamlfuse-1.png,33%)]] 2. 認証画面[[br]][[Image(gdocamlfuse-2.png,33%)]] [[Image(gdocamlfuse-3.png,33%)]] 3. 「アカウントにアクセスできるアプリ」から確認できる[[br]][[Image(gdocamlfuse-4.png,33%)]] * 自分で作成したクライアントIDを用いる場合は、次のように指定する * $ google-drive-ocamlfuse -headless -id XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com -secret XXXXXXXXXXXXXXXXXXXXXXX {{{ Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force Please enter the verification code: }}} * URL先から認証し、トークンを入力する {{{ Access token retrieved correctly. }}} * クライアントIDなどは{{{$HOME/.gdfuse/default/config}}}に、アクセストークンなどは {{{$HOME/.gdfuse/default/state}}} に保存される * config {{{ apps_script_format=json apps_script_icon= async_upload=true client_id=421658504262-iq0rh3uan1fn12r0767rac7ehj5atpmo.apps.googleusercontent.com client_secret=7ZpwiYjXmFcFaY09tP5LbFJW connect_timeout_ms=5000 curl_debug_off=false debug=false delete_forever_in_trash_folder=false docs_file_extension=true document_format=odt document_icon= download_docs=true drawing_format=png drawing_icon= form_format=zip form_icon= fusion_table_format=desktop fusion_table_icon= keep_duplicates=false large_file_read_only=false large_file_threshold_mb=16 low_speed_limit=0 low_speed_time=0 map_format=desktop map_icon= max_cache_size_mb=512 max_download_speed=0 max_memory_cache_size=10485760 max_retries=8 max_upload_chunk_size=1073741824 max_upload_speed=0 memory_buffer_size=1048576 metadata_cache_time=60 presentation_format=pdf presentation_icon= read_ahead_buffers=3 read_only=false spreadsheet_format=ods spreadsheet_icon= sqlite3_busy_timeout=5000 stream_large_files=false umask=0o022 verification_code= }}} * state {{{ access_token_date=2017-03-20T00:00:00.000Z auth_request_date=2017-03-20T00:00:00.000Z auth_request_id=XXXXXXXXXXXXXXXXXXXXXX last_access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX refresh_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX saved_version=0.6.7 }}} = aur:gdrivefs = * 作者が用意したクレデンシャルが埋め込まれており、コード書き換え以外に変更する手段が存在しない * gdrivefs 0.14.8-2に対するパッチ * PKGBUILD.diff {{{#!diff diff --git a/PKGBUILD b/PKGBUILD index dec95ef..2af649c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -28,6 +28,9 @@ build() { # Fix for oauth2client.util library patch -p1 < ../../issue_166.patch + # change api_credentials + patch -p1 < ../../cred.patch + python2 setup.py build } }}} * cred.patch {{{#!diff diff --git a/gdrivefs/conf.py b/gdrivefs/conf.py index 5310a3d..1496df3 100644 --- a/gdrivefs/conf.py +++ b/gdrivefs/conf.py @@ -11,8 +11,8 @@ class Conf(object): """Manages options.""" api_credentials = { - "web": { "client_id": "1056816309698.apps.googleusercontent.com", - "client_secret": "R7FJFlbtWXgUoG3ZjIAWUAzv", + "web": { "client_id": "564155291697-r72paq515fukt1uoc0bjofjl9fvsoerb.apps.googleusercontent.com", + "client_secret": "WVcC9DJTJzLdbjByhMJmwA68", "redirect_uris": [], "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token" }}}