25歳無職、マイナスからのプログラミング就活

25の無職がプログラマー就職キャンプのメンターからハッキリ「無理」っと言われ、PG勉強に奮起するブログ。 目的は「こんな自分でも社員で雇ってくれる会社様が現れる」そのことです。 こんなやつでも就職出来るんだ、俺だって頑張れば!、そんな風に思って貰える未来になれればいいと思います。 記事はプログラミング言語勉強や、英語学習の成果物が中心。 Unityがメインかも。 成果物を作って、何が何でも業界に就職してやるぜ!

Google driveをCUIで操作できるgdriveが急に死亡したので…

 

GitHub公開の本体ではOAuth認証が通らない。

急にってなったから困る

何が問題?

配布本体のOAuth認証が(多分)古くなっている事から起きている問題です。 なので、自分でOAuth認証(1.client_id 2.client_secret)を用意して、置換してやれば再び動きます。

用いた解決策

参考した解決法

以下原文。

  1. Set up OAuth:
    • Visit the Google Cloud Console
    • Go to the OAuth Consent tab, fill it, and save.
    • Go to the Credentials tab and click Create Credentials -> OAuth Client ID
    • Choose Other and Create.
    • Use the download button to download your credentials.
      • Credentialsタブの画面に(1.client_id 2.client_secret)があるので、特に落とす必要はない
    • Now you have both client ID and client secret in this credential file in the following form:
      • ↓ は落としたJSONの中身
{"installed":{"client_id": <your client id>,"project_id":"i-m-sky-bot","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret": <your client secret>,"redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}

2、Enable the Drive API:

  • Visit the Google API Library page.
  • Search for Drive. ←ここ謎だったけど
    • - ↑を選んで、有効化しろ!って事 - 一瞬 1.で作ったOAuthプロジェクトが現れるのかな?って深読みして焦った
  • Make sure that it's enabled. Enable it if not.

3、Now you just need to edit the binary and insert your credentials instead of the one hard coded : -

$ sed -i "s|367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com|<your client id>|g" path/to/the/executable/gdrive

$ sed -i "s|1qsNodXNaWq1mQuBjUjmvhoO|<your client secret>|g" path/to/the/executable/gdrive

Windowsの悲しみ

尚、Win10では sed(置換コマンド) は使えねぇのでバイナリ書き換えにはStirling_v131を使用 一応PowerShellで↓を使えばいいはずなんだけど、エラったので…

$data=Get-Content .\test.txt | % { $_ -replace "置換する文字列","置換後の文字列" }
$data | Out-File .\test.txt -Encoding UTF8

Google Cloud ConsoleのOAuth Consentに詳しい人教えて!

OAuth何日持つか知らないんだよねぇ…一応30日に設定したけど、意味あるのかな? その辺どうなんだろうね