LoginSignup
0
1

More than 3 years have passed since last update.

AWS CLIでAmazon Cognito(IDプール)を使ってみるサンプルメモ

Posted at

概要

IDプールを用いて認証されたID(Facebook連携)と、認証されていないIDを用いた認証を試す

メモ

認証されたID(Facebook)

前提

  • Facebook のデベロッパーアカウントでアプリ登録済み
  • テスト用のユーザートークン取得済み
  • Cognito のIDプールを作成済み(認証プロバイダーはFacebook)
    • IDプールのIDを確認済み

メモ

> aws cognito-identity get-id --identity-pool-id "[IDプールのID]" --logins "graph.facebook.com=[ユーザートークン]"
{
    "IdentityId": "ap-northeast-1:0cde9dab-cb6d-465e-903f-b339f612609a"
}
# ↑のIDは控えておく
> aws cognito-identity get-credentials-for-identity --identity-id "[取得したID]" --logins "graph.facebook.com=[ユーザートークン]"
{
    "Credentials": {
        "SecretKey": "", 
        "SessionToken": "", 
        "Expiration": , 
        "AccessKeyId": ""
    }, 
    "IdentityId": ""
}
# ↑控えておく

> export AWS_ACCESS_KEY_ID=xxxxx
> export AWS_SECRET_ACCESS_KEY=xxxx
> export AWS_SESSION_TOKEN=xxxxx
# あとはお好きに

認証されていないID

前提

  • 「認証されていない ID に対してアクセスを有効にする」にチェックして保存する

ScreenClip.png

メモ

> aws cognito-identity get-id --identity-pool-id "[IDプールのID]"
{
    "IdentityId": "ap-northeast-1:0cde9dab-cb6d-465e-903f-b339f612609a"
}
# ↑のIDは控えておく
> aws cognito-identity get-credentials-for-identity --identity-id "[取得したID]"
# あとは同じ

参考

ID プール (フェデレーティッドアイデンティティ) を使用する - Amazon Cognito https://docs.aws.amazon.com/ja_jp/cognito/latest/developerguide/identity-pools.html

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