# Next Gen - User token?

**URL:** <https://forums.knack.com/t/next-gen-user-token/19957>\
**Category:** Next-Gen\
**Created:** [October 10, 2025, 5:48pm UTC](https://forums.knack.com/t/next-gen-user-token/19957 "2025-10-10T17:48:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://forums.knack.com/u/Shan)\
**Post date:** [October 10, 2025, 5:48pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/1 "2025-10-10T17:48:19Z")

</div>

Is there a way to retrieve the user token in the next gen code? Knack.getUserToken() does not seem to exist anymore.

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [October 12, 2025, 12:35am UTC](https://forums.knack.com/t/next-gen-user-token/19957/2 "2025-10-12T00:35:20Z")

</div>

Hi @Shan, currently there is no way to do so, but myself and other users have requested this and some other Classic functions to be made available to NextGen.

---

<div class="post-metadata">

**Author:** ![Kara](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/kara/32/2717_2.png) [@Kara](https://forums.knack.com/u/Kara)\
**Post date:** [October 15, 2025, 5:20pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/3 "2025-10-15T17:20:26Z")

</div>

@Shan @StephenChapman The ability to get the user token is currently being QA’d, hopefully we can get it released in the next week or so.

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [November 22, 2025, 1:38am UTC](https://forums.knack.com/t/next-gen-user-token/19957/4 "2025-11-22T01:38:48Z")

</div>

Has this been completed yet?

---

<div class="post-metadata">

**Author:** ![Kara](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/kara/32/2717_2.png) [@Kara](https://forums.knack.com/u/Kara)\
**Post date:** [November 24, 2025, 4:26pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/5 "2025-11-24T16:26:41Z")

</div>

@IAmAKnacker @StephenChapman

Yes, this functionality was released a few weeks ago - [🚀 Week 43 / October 21: Next-Gen Custom JS & Security Enhancements - NEW | Knack](https://product.knack.com/changelog/50194)

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [November 26, 2025, 11:13pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/6 "2025-11-26T23:13:17Z")

</div>

I tried the sample code from the documentation and the browser is returning no user is currently logged in. This is obviously not true because I can browse all of the protected pages with my account. Is there anything special that needs to be done to get this to work?

Knack.ready().then(async () =\> {  
// Get current user information  
const user = await Knack.getUser();

if (user) {  
console.log(‘Current user:’, user);  
console.log(‘User email:’, user.email);  
console.log(‘User name:’, user.name);  
} else {  
console.log(‘No user is currently logged in’);  
}  
});

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [November 27, 2025, 1:59am UTC](https://forums.knack.com/t/next-gen-user-token/19957/7 "2025-11-27T01:59:19Z")

</div>

@Kara I can confirm the same with the same code above if calling immediately. It works the odd time, but the majority of times it doesn’t return a value, even when logged in.

---

<div class="post-metadata">

**Author:** ![Kara](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/kara/32/2717_2.png) [@Kara](https://forums.knack.com/u/Kara)\
**Post date:** [November 27, 2025, 2:20am UTC](https://forums.knack.com/t/next-gen-user-token/19957/8 "2025-11-27T02:20:48Z")

</div>

@StephenChapman @IAmAKnacker Thanks for letting me know, I’ve asked the team to look into this.

---

<div class="post-metadata">

**Author:** ![Kara](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/kara/32/2717_2.png) [@Kara](https://forums.knack.com/u/Kara)\
**Post date:** [November 30, 2025, 6:15pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/9 "2025-11-30T18:15:16Z")

</div>

There may have been a syntax error in the documentation (Left Single Quotation Mark (U+2018) and a Right Single Quotation Mark (U+2019), it’s been updated. Two engineers have tested the code and it’s worked correctly each time - after the correction, does it work consistently for you?

@StephenChapman @IAmAKnacker

```auto
Knack.ready().then(async () => {

  // Get current user information

  const user = await Knack.getUser();

  if (user) {

    console.log('Current user:', user);

    console.log('User email:', user.email);

    console.log('User name:', user.name);

  } else {

    console.log('No user is currently logged in');

  }

  // Check if the current user has a specific profile/role key

  try {

    const hasProfile = await Knack.hasProfileKey('profile_1'); // e.g., 'profile_1'

    if (typeof hasProfile === 'boolean') {

      console.log('Has profile_1?', hasProfile);

    }

  } catch (e) {

    // Swallow if not supported

  }

});

interface SchemaUser {

  id: string;

  email: string;

  name: string;

  status: string;

  profileKeys: KnackObjectProfileKey[];

  profileObjects: string[];

}

```

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [November 30, 2025, 8:51pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/10 "2025-11-30T20:51:11Z")

</div>

@Kara, still no luck. I made sure to correct the quotation marks (code below), but it works at least once and then never again after refreshing.  
I added a 250ms delay, and it worked okay. I wonder if the user details are not immediately available on `Knack.ready`?  
Not that this is super important, as I would only ever collect user details on scene render, as this would account for users logging in/out in the same session.

```auto
Knack.ready().then(async () => {

  // Get current user information
  const user = await Knack.getUser();
  if (user) {
    console.log('Current user:', user);
    console.log('User email:', user.email);
    console.log('User name:', user.name);
  } else {
    console.log('No user is currently logged in');
  }

});

```

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [November 30, 2025, 11:05pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/11 "2025-11-30T23:05:23Z")

</div>

Same here. Not working.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/3/331f2bd7382eaecc2a1341781bd60b37590927f3.png)

---

<div class="post-metadata">

**Author:** ![jake5](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/jake5/32/5464_2.png) [@jake5](https://forums.knack.com/u/jake5)\
**Post date:** [December 1, 2025, 3:28am UTC](https://forums.knack.com/t/next-gen-user-token/19957/12 "2025-12-01T03:28:51Z")

</div>

This is working on a next gen app for me:

```javascript
Knack.ready().then(async () => {

  Knack.on('page:render', async ({ pageKey }) => {
   
    try {
      const user = await Knack.getUser();
      if (user) {
        console.log('User email:', user.email);
        console.log('User name:', user.name);
        console.log('User id:', user.id);
        // do something here with user object
      } else {
        console.log('No user is logged in');
      }
    } catch (error) {
      console.error('Error identifying user: ', error);
    }
    
  });
  
});

```

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [December 2, 2025, 12:18pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/13 "2025-12-02T12:18:28Z")

</div>

Looks like that worked.

“Knack.on(‘page:render’, async ({ pageKey }) =\> {”

Seems to have fixed it. Thank’s Jake!

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [December 8, 2025, 9:31pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/14 "2025-12-08T21:31:15Z")

</div>

@Kara - How exactly do I get the session token. I looked at all of the values and can not find anything that indicates it is a session token. I see all of the fields returned in the request, but not the session token.

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [December 8, 2025, 9:34pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/15 "2025-12-08T21:34:58Z")

</div>

@IAmAKnacker, `user.token` is what you’re after:

```auto
const user = await Knack.getUser()
const token = user.token;

```

Here’s the full object:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/a/ad6552baf2bde8dccba4d574d03840295539edf5.png)

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [December 8, 2025, 9:43pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/16 "2025-12-08T21:43:25Z")

</div>

I am not getting the token returned. See below

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/3/3125a936f71f43413e6f46060071c8acf96da25a.png)

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [December 8, 2025, 10:26pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/17 "2025-12-08T22:26:07Z")

</div>

@Kara - am I not getting the token returned. Is there something that you guys need to do to fix this?

---

<div class="post-metadata">

**Author:** ![jake5](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/jake5/32/5464_2.png) [@jake5](https://forums.knack.com/u/jake5)\
**Post date:** [December 11, 2025, 6:00am UTC](https://forums.knack.com/t/next-gen-user-token/19957/18 "2025-12-11T06:00:25Z")

</div>

Not 100% sure if this will work (not sure how you are using the token?) but there is a value you can access in the user object on front end, user.values.password , which looks like it might be a token 🤔 I don’t have any front end code which calls a knack api to test if this is actually functional, but try it out?

It also looks like next gen uses Local Storage to keep track of the refreshToken, but not sure if it will allow api calls with that. A knack internal engineer would know; I am not one ☹

I also do not get anything back for user.token on the front end, not sure if Stephen has special powers somehow or was maybe accidentally testing on classic apps?

---

<div class="post-metadata">

**Author:** ![IAmAKnacker](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@IAmAKnacker](https://forums.knack.com/u/IAmAKnacker)\
**Post date:** [December 11, 2025, 9:21pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/19 "2025-12-11T21:21:45Z")

</div>

That’s just an encrypted version of the password, not the session token. I need the token to authenticate to the view-based APIs

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [December 11, 2025, 11:49pm UTC](https://forums.knack.com/t/next-gen-user-token/19957/20 "2025-12-11T23:49:48Z")

</div>

@IAmAKnacker, I suggest you raise a ticket with [support@knack.com](mailto:support@knack.com) if you still can’t see that user token, as it should be appearing in that getUser() object.

[Next page](https://forums.knack.com/t/next-gen-user-token/19957.md?page=2)
