{"id":16639007,"url":"https://github.com/fedemitic/auth0-users","last_synced_at":"2025-10-28T12:31:01.935Z","repository":{"id":57187096,"uuid":"120354956","full_name":"FedeMITIC/auth0-users","owner":"FedeMITIC","description":"Retrieve user from Auth0 servers using a JWT","archived":false,"fork":false,"pushed_at":"2018-02-06T15:58:03.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T12:19:25.555Z","etag":null,"topics":["auth0","authorization","jwt","jwt-authentication"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FedeMITIC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-05T20:02:49.000Z","updated_at":"2020-12-20T14:24:12.000Z","dependencies_parsed_at":"2022-08-28T13:00:14.464Z","dependency_job_id":null,"html_url":"https://github.com/FedeMITIC/auth0-users","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FedeMITIC%2Fauth0-users","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FedeMITIC%2Fauth0-users/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FedeMITIC%2Fauth0-users/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FedeMITIC%2Fauth0-users/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FedeMITIC","download_url":"https://codeload.github.com/FedeMITIC/auth0-users/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238651171,"owners_count":19507732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth0","authorization","jwt","jwt-authentication"],"created_at":"2024-10-12T07:04:48.175Z","updated_at":"2025-10-28T12:31:01.644Z","avatar_url":"https://github.com/FedeMITIC.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Auth0-users\n\n# Purpose of this package\nAuht0-users is a simple package used to query the `/tokeninfo` endpoint provided by Auth0 services.\nThis endpoint contains all the data of the user associated with the token/jwt sent.\nThe data returned from the server cannot be customized using this package, but must be edited using the Auth0 dashboard.\n\n# Usage\nFirst, load the package in your code:\n\n`const getTokenInfo = require('auth0-retrieve-users');`\n\nThen, call the function getTokenInfo to retrieve the data\n\n`getTokenInfo(token, endpointUrl);`\n\n`getTokenInfo` always returns a promise, so chain it with `.then()` and `.catch()`\nmethods to handle promise resolution and rejection.\n\nThis package can also be used as a middleware to retrieve the user data when he/she's\nquerying one of your API endpoint. See the example commented code below:\n\n```\nconst getUser = (req, res, next) =\u003e                     \n  getTokenInfo(req.headers.authorization)            \n    .then((user) =\u003e {\n      res.locals.user = user;                           // Saves the data in res.locals.user\n      next();                                           // Pass the control to the next middleware\n    })\n    .catch((error) =\u003e {\n      console.log(error);                               // Logs errors\n      res.status(error.statusCode).send(error.message); // Reply to the client\n    });\n```\nWhere `req.headers.authorization` contains the token of the user. The user data will be saved in `res.locals.user` and will be accessible to every route of your application. Then where you define routing, just add the middleware to the call stack:\n`app.use('/your/api/endpoint', getUser, your_api_endpoint);`\n\n**Alternatives:** `getTokenInfo` can be called in different ways:\n1) with **1** parameter, `token`: in this case debug mode is disabled and the URL will be read from a .env file.\n2) with **2** parameters, `token`, `url`: in this case debug mode is disabled too, but the URL inserted in the `url` parameter s\nwill be used.\n3) with **3** parameters, `token`, `url`, `true`: this is like case 2. with debug enabled.\n4) with **3** parameters, `token`, `undefined`, `true`: this is like case 1. with debug enabled.\n\n**Debug:** debug can be enabled by calling `getTokenInfo` functions with third parameter set to true.\nIn debug mode, the full response object and all the variables will be printed on stdout.\n# Disclaimer\nThis package doesn't check the integrity of the JWT/Token: it simply extracts it from the `authorization header`, parses it from the format `'Bearer \u003ctoken\u003e'` and forwards it to Auth0 servers. For this reason, it is recommended to check the token validity **before** calling this function, using for example the package `express-jwt` if using `express`.\n\n**I don't work for and I'm not endorsed by Auth0, and this isn't a official package provided by Auth0. See LICENSE for more details.**\n\n# Comment, suggestions\nComments and suggestions are always welcomed.\n\n# TODO\n- Write more tests\n- Add some badge in the readme","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedemitic%2Fauth0-users","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffedemitic%2Fauth0-users","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffedemitic%2Fauth0-users/lists"}