LoginSignup
0
0

More than 3 years have passed since last update.

aws-cliでCogtnitoが発行したIDトークンを使い一時クレデンシャルを発行する

Posted at

概要

aws-cliでCogtnitoが発行したIDトークンを使い一時クレデンシャルを発行する。

※ ↓の 外部プロバイダーの認証フロー拡張(簡略化)認証フロー を使う
https://docs.aws.amazon.com/ja_jp/cognito/latest/developerguide/authentication-flow.html

コマンド

1.まず GetId を叩く。

aws cognito-identity get-id --cli-input-json file://get-id.json

get-id.jsonの中身

{
    "IdentityPoolId": "ap-northeast-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // IDプールのID
    "Logins": {
        // ↓リージョン/ユーザプールID : 取得したIDトークン
        "cognito-idp.ap-northeast-1.amazonaws.com/ap-northeast-1_xxxxxxxxx": "ey..."
    }
}


* IDプールの設定で、認証プロバイダーとしてIDトークン発行時に使用している、ユーザープールID、アプリクライアントID が設定されている必要あり。

https://docs.aws.amazon.com/cognitoidentity/latest/APIReference/API_GetId.html
https://docs.aws.amazon.com/cli/latest/reference/cognito-identity/get-id.html

2.次に、GetOpenIdTokenForDeveloperIdentity を叩く

aws cognito-identity get-credentials-for-identity --cli-input-json file://get-credentials.json

get-credentials.jsonの中身

{
    "IdentityId": "ap-northeast-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // GetIdのレスポンスの値
    "Logins": {
        // GetIdで使ったものと同じ値
        "cognito-idp.ap-northeast-1.amazonaws.com/ap-northeast-1_xxxxxxxxx": "ey..."
    }
}
0
0
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
0
0