# Invalid token error while using management API

**URL:** <https://community.auth0.com/t/invalid-token-error-while-using-management-api/9078>\
**Category:** Get Help\
**Tags:** token, authorization, management-api\
**Created:** [December 29, 2017, 12:19am UTC](https://community.auth0.com/t/invalid-token-error-while-using-management-api/9078 "2017-12-29T00:19:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![0x142857](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/0x142857/32/7541_2.png) [@0x142857](https://community.auth0.com/u/0x142857)\
**Post date:** [December 29, 2017, 12:19am UTC](https://community.auth0.com/t/invalid-token-error-while-using-management-api/9078/1 "2017-12-29T00:19:17Z")

</div>

```
const auth0 = new auth0.WebAuth({
  ...clientConfig,
  responseType: 'token id_token',
  scope: 'openid profile'
})

auth0.authorize({ connection: 'github' })

// Successfully redirected to callback page

auth0.parseHash({}, (err, res) => {
  const management = new auth0.Management({
    domain: clientConfig.domain,
    token: res.idToken
  })
  management.getUser(res.idTokenPayload.sub, (err, res) => {
    // Error
    // 401 invalid token
  })
})

```

Using `auth0-js` v9, however v8 didn’t work either

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [December 29, 2017, 6:31pm UTC](https://community.auth0.com/t/invalid-token-error-while-using-management-api/9078/2 "2017-12-29T18:31:38Z")

</div>

You’re trying to use an ID token against the Management API so **the 401 is the expected behavior for new tenants/domains or an existing tenants where the _Allow ID Tokens for Management API v2 Authentication_ toggle was disabled**.

---

<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:** [March 2, 2018, 5:57am UTC](https://community.auth0.com/t/invalid-token-error-while-using-management-api/9078/3 "2018-03-02T05:57:57Z")

</div>


