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.

Get meta data of currently logged in user.

See original GitHub issue

Describe the problem

I’ve been looking at the documentation but I can’t find any information about it. Every user in the system has metadata, in that metadata are some data that I need, here’s the flow:

  1. User logs in (using web login, auth0.webAuth.authorize)
  2. If login successful, get user metadata.

Here’s how I’m trying to do it, based on google search results directing me to some issues in this repo, and also the Github’s search bar, like this one https://github.com/auth0/react-native-auth0/issues/197

const credentials = await auth0.webAuth.authorize({
  scope: 'openid profile email read:current_user',
  connection
});

const { accessToken } = credentials;
const { sub } = await auth0.auth.userInfo({ token: accessToken });
const user = await auth0.users({ token: accessToken }).getUser({ id: sub });

I would get:

Bad Request: Bad HTTP authentication header format
    at responseHandler (http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:263790:11)
    at http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:263818:18
    at http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:143005:24
    at flush (http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:143688:11)
    at tryCallOne (http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:3509:14)
    at http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:3610:17
    at http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:30747:21
    at _callTimer (http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:30635:9)
    at _callImmediatesPass (http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:30674:7)
    at MessageQueue.callImmediates [as _immediatesCallback] (http://192.168.1.4:8081/index.bundle?platform=ios&dev=true&minify=false:30891:14)

What was the expected behavior?

Reproduction

Please read the description above.

Environment

  • Version of this library used: 2.6.0
  • Which framework are you using, if applicable:
  • Other modules/plugins/libraries that might be involved:
  • Any other relevant information you think would be useful:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Widcketcommented, Jan 29, 2021

There are essentially 2 ways of accessing the user’s metadata:

  1. Make a request from your app to the Management API. You’ll need to request an AT for that API (by including the Management’s API identifier in the audience array -> https://YOUR_DOMAIN/api/v2/) and include the following scope read:current_user.
  2. Use a Rule to add the metadata directly onto the ID Token.

there are configurations to be done on the auth0 side to make that happen, is that right?

Exactly, please refer to this docs page.

0reactions
aprilmintacpinedacommented, Jan 30, 2021

Thank you very much for the help, we will try the idToken approach 🙇

Read more comments on GitHub >

github_iconTop Results From Across the Web

get_user_meta() | Function - WordPress Developer Resources
get_metadata() wp-includes/meta.php. Retrieves the value of a metadata field for the specified object type and ID.
Read more >
Add current product to the current logged in user meta data
Now to retrieve this custom user meta data and the WC_Product Object (from the product ID), you will use: $product_id = get_user_meta( get_ ......
Read more >
Check for user meta data at Login - WordPress Stack Exchange
To accomplish this, I have added the following code to my functions.php file. However, with this in place, it won't let anyone log...
Read more >
Understand How Metadata Works in User Profiles - Auth0
Auth0 provides a comprehensive system for storing metadata in the Auth0 user profile. You can use metadata to do the following activities:.
Read more >
Get all user meta data by user ID in wordpress - Boopathi Rajan
If you want to get all user meta data by using id then use get_user_meta() function. For example user id is 25. Use...
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