2
0

More than 1 year has passed since last update.

amplifyで作成したCognitoのユーザープールのカスタム属性をAuthで取得する 2023/09/15

Posted at

amplifyでCognitoを作成

下記の内容を参考にCognitoを作成しましょう。
その際、カスタム属性の作成はできません。できるのは標準属性のみが作成できます。

https://docs.amplify.aws/cli/auth/overview/

cognitoにカスタム属性を追加

awsコンソールを表示してcognitoのユーザープールに移動します。上記で作成したユーザープールを選択して、サインアップエクスペリエンスタブを選択してカスタム属性を追加してください。

amplifyのライブラリでカスタム属性を取得

import { useAuthenticator } from '@aws-amplify/ui-react'
const {user} = useAuthenticator()

上記を使って、attributes(属性)を取得します。その際、自分は取得できませんでした...
しかし、下記のようにamplify/backend/auth/{ユーザープールのID}/cli-inputs.json

"userpoolClientReadAttributes": [
      "email",
      "name",
      "custom:test"
]

を設定したら読めるようになりました。

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