简体   繁体   English

颤振安全存储如何存储不记名令牌?

[英]flutter secure storage how to store bearer token?

I try to store bearer access token to flutter secure storage.我尝试存储不记名访问令牌以颤动安全存储。 But I only able to access to body part details.但我只能访问身体部位的详细信息。 i print jsonDecode(res.body) i can get all the details.我打印 jsonDecode(res.body) 我可以获得所有详细信息。 but i write await storage.write(key: "token", value: data["access_token"]);但我写了 await storage.write(key: "token", value: data["access_token"]); i get null return.我得到空回报。

How can I access to Body>Data > Accesstoken to get token and storage into secure storage?如何访问 Body>Data > Accesstoken 以获取令牌和存储到安全存储中?

                         var data = jsonDecode(res.body);
                         
                                            
                          await storage.write(key: "token", value: data["access_token"]);
                        
                         
                        
                          Navigator.pushReplacement(
                              context, SlideRightRoute(page: ooww()));
                          break;

enter image description here在此处输入图像描述

The token is inside the key data.令牌位于密钥数据中。 So you have to use所以你必须使用

var data = jsonDecode(res.body);              
await storage.write(key: "token", value: data['data']["access_token"]);
                        

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM