インストール
$ (sudo) gem install soracom # 環境により sudo が必要となる場合があります。
としてインストールすることで、ライブラリおよびコマンドラインインターフェース (soracom
コマンド) が導入されます。
初期設定
Version 1.1 以降では、プロファイル を指定することで、簡単に操作するユーザーを切り替えることが可能となりました (デフォルトでは、default
プロファイルが使用されます)。また、従来の環境変数による指定も引き続き利用可能です。
プロファイルの作成
認証方法は、以下の 3 種類です。
- (推奨) 認証キー (AuthKeyId & AuthKey) を使用する方法 (Operator/SAM ユーザー共通)
- Opertor の認証 (E メール&パスワード)
- SAM ユーザーの認証 (オペレータ ID とユーザー名・パスワード)
ここでは、事前に SORACOM ユーザーコンソールで認証キーを作成しておき、CLI を使ってプロファイルを作成します。
~$ soracom configure --profile default
--- SORACOM CLI setup ---
This will create .soracom directory under /Users/sorao and place 'default.json' in it.
Please select which authentication method to use.
1. Input AuthKeyId and AuthKey *Recommended*
2. Input Operator credentials (Operator Email and Password)
3. Input SAM credentials (OperatorId and UserName and Password)
select(1-3)> 1
authKeyId: keyId-abcdefabcdefabcdefabcdefabcdefabcdef
authKey: (エコーバックされません)
wrote to /Users/sorao/.soracom/default.json
認証が行えるかどうか、確認しておきましょう。
~$ soracom auth --profile default
testing authentication...
authentication succeeded.
:
: