# Connect the auth api to express

**URL:** <https://community.auth0.com/t/connect-the-auth-api-to-express/117029>\
**Category:** Get Help\
**Tags:** management-api, roles\
**Created:** [September 24, 2023, 1:45pm UTC](https://community.auth0.com/t/connect-the-auth-api-to-express/117029 "2023-09-24T13:45:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/asi/32/51132_2.png) [@asi](https://community.auth0.com/u/asi)\
**Post date:** [September 24, 2023, 1:45pm UTC](https://community.auth0.com/t/connect-the-auth-api-to-express/117029/1 "2023-09-24T13:45:46Z")

</div>

hello friends !  
my name is Asi im working as web developer, and im trying to to use the auth0 roles and premissions, im trying to implement it on my project, im working as client Angular and as back-end my server is express.  
and i dont understand how to use it well in order to use the roles and presmissions,  
now im trying to implement the code from the website docomunation and it dosent work for me.

maybe becuase im using ES-6 and it want only the old way… not sure  
maybe someone here can explain me how to implement that auth0 on my server express?  
this is my code for now -

```auto
import { auth, requiresAuth } from "express-openid-connect";

const config = {
  authRequired: false,
  auth0Logout: true,
  baseURL: "http://localhost:3000",
  clientID: "JbmkcjuyYCurzhyQjny3dkxb3YroMPXX",
  issuerBaseURL: "http://localhost:4200",
  secret: "45donIsBL8xBvBCT1mb49-O0DA5Wzt1hjfYfxpChkloQWIDETGbEVpSfIl8Md6PR",
};

// The `auth` router attaches /login, /logout
// and /callback routes to the baseURL
app.use(auth(config));

// req.oidc.isAuthenticated is provided from the auth router
app.get("/", (req, res) => {
  res.send(req.oidc.isAuthenticated() ? "Logged in" : "Logged out");
});

// The /profile route will show the user profile as JSON
app.get("/profile", requiresAuth(), (req, res) => {
  res.send(JSON.stringify(req.oidc.user, null, 2));
});

```

it gives me error -

```auto
SyntaxError: Named export 'requiresAuth' not found. The requested module 'express-openid-connect' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'express-openid-connect';
const { auth, requiresAuth } = pkg;

```

if someone can help me ill be very greatfull !!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 27, 2023, 12:58pm UTC](https://community.auth0.com/t/connect-the-auth-api-to-express/117029/3 "2023-09-27T12:58:58Z")

</div>

Hi @asi,

Have you tried using the method described in the error message, i.e.

```auto
import pkg from 'express-openid-connect';

```

This may help explain it:

> <https://stackoverflow.com/questions/70605320/named-export-types-not-found-the-requested-module-mongoose-is-a-commonjs-mo>

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 11, 2023, 12:59pm UTC](https://community.auth0.com/t/connect-the-auth-api-to-express/117029/4 "2023-10-11T12:59:22Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
