score:0
Accepted answer
So I wasn't aware of the User Management API
To solve the issue of getting the user data to confirm authentication within my API server I decoded the JWT token server-side which contained the user ID, then I used the ID within a call to the management API to get the full user data.
The auth token for the call to the management API can be generated within the API dashboard on the Auth0 website
app.get('/authed', jwtCheck, async (req,res) =>{
let token = req.headers.authorization.substring(7, req.headers.authorization.length)
// GET THE DATA FOR THE LOGGED IN USER WHO MADE THE CALL
var decoded = jwt_decode(token);
console.log(decoded.sub)
axios.get(`https://************.us.auth0.com/api/v2/users/${decoded.sub}`,{
headers:{
Authorization:`Bearer *`,
}
}).then((res) =>{
console.log(res)
}).catch(e =>{
console.log(e)
})
res.send("secured resource")
})
Source: stackoverflow.com
Related Query
- Accessing Auth0 logged in user from within an API?
- React app using Laravel for API and user login. Question about retrieving currently logged in user from database
- React hooks: accessing up-to-date state from within a callback
- Accessing a part of reducer state from one reducer within another reducer
- Accessing a reducer state from within another reducer
- Is it OK to make a REST API request from within a Redux reducer?
- Accessing the state from within a redux-observable epic
- Accessing Passport's req.user within React (ES6)? API call returns req.user as undefined
- Accessing data from rest api with reactjs
- How to get the user repo from github API using react?
- Accessing individual array elements in React called from API
- How to use useEffect and the Context API to check if a user is logged in and protect a route?
- User Authentication for API from React App
- Prevent an user from accessing other routes - ReactJS - React-Router -
- Is there a way to remember a string from a user session, even after the user has logged out, so everytime they come in, it autofills?
- How to make aspecific API call from within a Line Chart class in ReactJS using react-chartjs-2?
- Hiding React Src From User Until Logged In
- Accessing Cookies API from a React WebExtension
- Accessing child component refs from within a parent component
- How to I prevent user from accessing the page of my react app directly by entering the URL, and redirect them back to login page
- Fetching User Data From ID: WP REST API
- Prevent user from go back to the login page when user logged in React js
- Too many re-renders when accessing data from an API in React
- How to prevent the user from accessing other parts of the page until the customized alert box is closed?
- Can I check if a Auth0 user is logged in already at the level of my custom NextJS _app.js?
- how can i get multiple values to display from a mapped api which has multiple images within the already looped array?
- Accessing upload image from Laravel Api in ReactJs Component
- React Hooks and Fetch: How to update a table based on a user input from an API search
- ReactJS Fetch User Data from API and add to table
- Accessing Store's State in Redux From Within A Reducer Function
More Query from same tag
- Updating props from child component in React JS
- How to get Laravel validation errors in react component which is in Laravel blade
- Cannot read property '_currentElement' of null
- Showing loading indicator while writing data to Firestore
- Forwarding InnerRef on a styled-component gives typescript error
- Highlight current page in bootstrap with react
- Receiving 'Error: Cannot find module' using browserify, gulp, react.js
- Using Async and await with Fetch (in Actions of Redux) ReactJS
- React component state not updating as expected
- Relay Cache with Flux Pattern?
- React-admin component does not use dataprovider to call api
- Using for loops and switch cases in React to dynamically render different components
- ReactJS: How to load SVG dynamically from an const object?
- access array member of type object in javascript
- React Code rendering as text and components are not being initiated
- get backend var from php into reactjs via webpack
- Put function that returns promise in redux state
- React js test boolean prop with Jest
- Using react-apollo 2.1 mutations with react lifecycle methods
- _worker.default is not a constructor in react js
- Is there a way to update React state in child without passing state and setter function as props?
- Accordion SideBar Menu using Nav components with react-bootstrap
- React-router subdomain routing
- Having 2 forms of strings in an array and converting between them dynamically at run time in React JS
- Multiple `setState` not synchronized - if one uses a value obtained from `await`
- Add "%" suffix to value displayed inside react-toolbox input number
- Force new line on minified react build
- React recreates my component on each material ui tab switch
- Nextjs how to not unmount previous page when going to next page (to keep state)
- How to send a image jpg/png file from react to express server