Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I retrive UUID from MySQL in my Flutter app? #53

Open
bestofman opened this issue Mar 28, 2023 · 0 comments
Open

How can I retrive UUID from MySQL in my Flutter app? #53

bestofman opened this issue Mar 28, 2023 · 0 comments

Comments

@bestofman
Copy link

I have a mysql table like this:

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

And create a binary UUID like following within my NodeJS application:

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

Then use an insert statement to put the new user inside the table and sign a json web token as follows:

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

But at the front end when I try to extract user_id from the given token using the following code:

  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!);

I see something like below when I print out decodedToken:

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

Why this happens and how can I fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant