首页 > 解决方案 > Not be able to console log Auth0 user_metadata. I created a custom rule I also see the data in postman.What am I doing wrong

问题描述

** I'm doing as following, I already created a custom rule.**

 componentDidMount() {
            console.log(token)
            let response = fetch('https://DOmain.eu.auth0.com/userinfo', {
                method: 'GET',
                headers: {
                    Authorization: 'Bearer ' + token,
                },
            }).then((response) => response.json())
                .then(responseJson => data = responseJson).then(console.log(data.nickname));


            const  metadata = data["https://Domain.eu.auth0.com/user_metadata"]
            console.log(metadata);  

   }

My rule:
My rule

标签: metadataauth0

解决方案


您设置的规则看起来不错,但由于命名空间是 Auth0 域,因此无法正常工作

任何非 Auth0 HTTP 或 HTTPS URL 都可以用作命名空间标识符,并且可以使用任意数量的命名空间

试一试使用备用命名空间 example 'https://myapp.example.com/',您应该一切顺利!

作为旁注,我会尽量避免添加所有可能usermetadata导致idtoken生成的令牌太大的令牌。您还应该确保所包含的数据不敏感并且可以被披露。一些可能有帮助的项目,请在此处快速阅读:https ://auth0.com/docs/metadata和此处:https ://auth0.com/docs/scopes/current/custom-claims ,以帮助您一路走好!


推荐阅读