如何在我的 Flutter 应用程序中从 MySQL 检索 UUID?

问题描述 投票:0回答:0

我有一个这样的mysql表:

CREATE TABLE IF NOT EXISTS auth (
  id BINARY(16) PRIMARY KEY);

并在我的 NodeJS 应用程序中创建一个二进制 UUID,如下所示:

user_id = id: <Buffer 11 ed cd 15 15 37 82 00 bf fe a5 5d 53 c7 95 d9>

然后使用插入语句将新用户放入表中并签署一个 json 网络令牌,如下所示:

  const jwt = jwt.sign(
    {user_id : user_id},
    process.env.JWT_KEY!,
    {
      expiresIn: process.env.JWT_EXPIRES_IN,
    }
  );

但是在前端,当我尝试使用以下代码从给定的令牌中提取

user_id
时:

  final responseData = json.decode(response.body);
  if (responseData['error'] != null) {
    throw HttpException(responseData['error']['message']);
  }
  _token = responseData['token'];
  Map<String, dynamic> decodedToken = JwtDecoder.decode(_token!);

当我打印出来时,我看到类似下面的内容

decodedToken

 {type: Buffer, data: [17, 237, 205, 21, 21, 55, 130, 0, 191, 254, 165, 93, 83, 199, 149, 217]}

为什么会发生这种情况,我该如何解决?

mysql node.js flutter jwt uuid
© www.soinside.com 2019 - 2024. All rights reserved.