LoginSignup
4
1

More than 3 years have passed since last update.

CLI環境でFirebaseへログインする方法

Last updated at Posted at 2020-06-06

はじめに

Raspberry pi3(CLI only)にFirebaseの環境を構築しようとした際、Firebaseのログイン処理に苦戦したため、備忘録として残しておきます。

どこで詰まったか

$ firebase login
i  Firebase optionally collects CLI usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.

? Allow Firebase to collect CLI usage and error reporting information? Yes
i  To change your data collection preference at any time, run `firebase logout` and log in again.

Visit this URL on this device to log in:
https://accounts.google.com/o/oauth2/・・・・・・

Waiting for authentication...

ここでfirebase-cliを利用する装置上で、Webブラウザ(GUI)でURL(Visit this URL on this device to log in:の下に記載されている)へアクセスし、Googleアカウントの認証を行う必要がある。
しかし、うちのRaspberry piにGUIは入っていない。

解決策

--no-localhostオプションを追加し、URLの発行だけRaspberry pi上で行い、他のGUIが入ってる装置でGoogle認証を行う。

$ sudo firebase login --no-localhost
[sudo] password for hub:

Visit this URL on any device to log in:
https://accounts.google.com/o/oauth2/auth?・・・・

? Paste authorization code here:

Visit this URL on this device to log in:の下に記載されているURLに、他の装置上のブラウザでアクセスする。
GoogleアカウントへのログインとCLI利用の許可処理を行うと、パスコードが発行されるのでそれをコピーする。
コピーしたパスコードをRaspberry piに入力すると、「Success! Logged in as username」が表示され、無事Firebaseのログイン処理が完了する。

補足

Error: Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth

上記のエラーメッセージが出た場合はsudo firebase login --no-localhost --reauthで改めて試すとログインできる。

参考文献

4
1
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
4
1