question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JWT metadata missing on User object

See original GitHub issue

Goals

I have specified metadata fields in the custom JWT authentication settings, but these fields do not appear on the user object after logging in. I am working with realm-web version 0.9.0

Expected Results

When using the Stitch SDK these fields could be found on the user.profile.data object (mongodb-stitch-browser-sdk version 4.8.0).

Actual Results

The user.profile.data object does not exist. See screenshots.

Steps to Reproduce

Use custom JWT authentication with metadata fields. Login in the browser and check the logged in user object.

Code Sample

const loggedInUser = await realmApp.logIn(Realm.Credentials.jwt(jwtString))
console.log(loggedInUser.profile.data) // undefined

Version of Realm and Tooling

  • Realm JS SDK Version: realm-web 0.9.0
  • Node or React Native: Web
  • Client OS & Version: Chrome 85 on macOS 10.15.7
  • Which debugger for React Native: None

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kraenhansencommented, Feb 8, 2021

@andrew-whitmore short answer is no. #3481 fixed this for Realm Web (since that was the SDK the original poster was using), but we still have outstanding issues adding this across our other SDKs. I’ll ensure these issues are tracked and get back here with a link so you can follow the progress.

1reaction
andrew-whitmorecommented, Feb 8, 2021

@kraenhansen - should this work now?

I have version 10.2.0 of realm using a custom JWT authentication provider and custom profile data is not working as expected. As a work around we are currently using the birthday field on profile to pass a value down that we need. See screen shot Screenshot 2021-02-08 at 16 24 36

then after login If I inspect the profile like so

console.log(user.profile);

then the opu field is not present.

{"birthday": "7523", "firstName": "ALEX M", "lastName": "DUMMER", "name": "770540"}

Thanks

Andy

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rule to add user_metadata attributes to user object in ...
Hi John,. Yeah the idToken or the user object through useAuth0 through the auth0-react package.
Read more >
Custom JWT Authentication provider metadata - MongoDB
I have managed to connect to Mongo Realm. I created a user but I was not able to see the user-created in Realm....
Read more >
JSON Web Token Introduction - jwt.io
Learn about JSON Web Tokens, what are they, how they work, when and why you should use them.
Read more >
JWT: The Complete Guide to JSON Web Tokens
A Step-by-Step Guide for learning JSON Web Tokens, including signatures, single page web application User Authentication and Session ...
Read more >
JWT authentication: Best practices and when to use it
However, this is not ideal for users, who may have their tokens expired for no reason. One way to do it is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found