我想獲得 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 Name 沒有價值? 在此處輸入影像描述
uj5u.com熱心網友回復:
你應該使用
ak=JSON.parse(localStorage.getItem('oidc.user:https://accounts.zerotier.com/auth/realms/zerotier:zt-central'));
alert(JSON.stringify(ak['access_token]));
這會將 JSON 轉換為 Js 陣列,因此您可以獲得所需的引數
uj5u.com熱心網友回復:
ak=JSON.parse(localStorage.getItem('oidc.user:https://accounts.zerotier.com/auth/realms/zerotier:zt-central'));
alert(JSON.stringify(ak['access_token']));
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/505637.html
標籤:javascript
