Help us understand the problem. What is going on with this article?

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

概要

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away