我想得到access_token值,但是它得到了我不想要的id_token。这是我的代码,如果你能分享我想要的东西,我会很感激的。
alert(localStorage.getItem('oidc.user:https://accounts.zerotier.com/auth/realms/zerotier:zt-central'));
请看下面的图片,这样你就知道我想要得到什么了。

更新代码
alert(Object.keys(JSON.parse(localStorage.getItem('oidc.user:https://accounts.zerotier.com/auth/realms/zerotier:zt-central')))[2]);只带来Access_Token名称没有值?在这里输入图像描述
发布于 2022-09-08 11:42:36
你应该用
ak=JSON.parse(localStorage.getItem('oidc.user:https://accounts.zerotier.com/auth/realms/zerotier:zt-central'));
alert(JSON.stringify(ak['access_token']));这会将JSON转换为Js数组,这样就可以获得所需的参数。
https://stackoverflow.com/questions/73648321
复制相似问题