wiki:TipAndDoc/service/Google/OAuth

Version 8 (modified by mitty, 6 years ago) (diff)

--

setup project

  • Google APIコンソールを初めて開くとライブラリにリダイレクトされる
  • https://console.developers.google.com/ からプロジェクトを作成し、必要なAPIを有効にしたうえでOAuthのクライアントIDとクライアントシークレットを作成する
  • 自分で作成したプロジェクトのクライアントIDを用いることで、APIの発行状況やエラー発生件数などがダッシュボードから確認できるようになる
  1. 初めてダッシュボードにアクセスした際には、利用規約への同意が求められる
  2. プロジェクトの新規作成
  3. 使用するAPIの有効化
  4. 認証情報の作成
  5. OAuth認証時の同意画面に表示する情報の設定
    • サービス名は「My OCAMLDrive」としている
  6. アプリケーションの種類は「その他」とする
  7. クライアントIDが生成され、表示もしくはjson形式でダウンロードできるようになる
    {"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とシークレットを用いて認証要求を行うと、以下のように表示される
  9. 認証後、表示されたトークンをアプリケーションに設定する

aur:google-drive-ocamlfuse

  1. デフォルトでは作者 alessandro.strada@gmail.com が用意したクライアントIDが用いられる
  2. 認証画面
  3. 「アカウントにアクセスできるアプリ」から確認できる
  • 自分で作成したクライアント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
      • PKGBUILD

        diff --git a/PKGBUILD b/PKGBUILD
        index dec95ef..2af649c 100644
        a b build() { 
        2828  # Fix for oauth2client.util library 
        2929  patch -p1 < ../../issue_166.patch 
        3030 
         31  # change api_credentials 
         32  patch -p1 < ../../cred.patch 
         33 
        3134  python2 setup.py build 
        3235} 
        3336 
    • cred.patch
      • gdrivefs/conf.py

        diff --git a/gdrivefs/conf.py b/gdrivefs/conf.py
        index 5310a3d..1496df3 100644
        a b class Conf(object): 
        1111    """Manages options.""" 
        1212 
        1313    api_credentials = { 
        14         "web": { "client_id": "1056816309698.apps.googleusercontent.com", 
        15                  "client_secret": "R7FJFlbtWXgUoG3ZjIAWUAzv", 
         14        "web": { "client_id": "564155291697-r72paq515fukt1uoc0bjofjl9fvsoerb.apps.googleusercontent.com", 
         15                 "client_secret": "WVcC9DJTJzLdbjByhMJmwA68", 
        1616                 "redirect_uris": [], 
        1717                 "auth_uri": "https://accounts.google.com/o/oauth2/auth", 
        1818                 "token_uri": "https://accounts.google.com/o/oauth2/token" 

Attachments (18)

Download all attachments as: .zip