Auto0とは
認証を担うIDaaS
フロントとバックで認証を共有する
フロント
-
UserIdTokenを取得する
-
reactなら
getAccessTokenWithPopup
(local)かgetAccessTokenSilently
-
Auth0Provider
にaudience
を指定するとJWTで取得できる
-
fetch
のheaderに設定する
fetch(userDetailsByIdUrl, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
-
loginWithRedirect
で実装するとリダイレクト後のクエリストリングにcode
とstate
が入ってくる
-
多分これでログインユーザーを判定して、react上のauth0と連携してると思う
-
あとからクエリを除けばOK
バック
Node.jsでユーザーの情報を取得する
-
Auth0 Management APIを使用してNode.jsでユーザーを管理してみたを参考に進める
-
Client is not authorized to access \"https://dev-jb3jt2m4.jp.auth0.com/api/v2/\". You need to create a \"client-grant\" associated to this API.....
が出た
-
Auth0 Manegement API
->Machine to Machine Applications
-
Client has not been granted scopes: read:users
が出た
-
Auth0 Manegement API
->Machine to Machine Applications
->Ahthorized
のドロップダウンを展開して、read:users
を有効にする
ログイン画面のカスタマイズ