# Getting last password reset value in .Net Core service

**URL:** <https://community.auth0.com/t/getting-last-password-reset-value-in-net-core-service/26123>\
**Category:** Get Help\
**Created:** [June 4, 2019, 6:29pm UTC](https://community.auth0.com/t/getting-last-password-reset-value-in-net-core-service/26123 "2019-06-04T18:29:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajaauthowner](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rajaauthowner/32/13366_2.png) [@rajaauthowner](https://community.auth0.com/u/rajaauthowner)\
**Post date:** [June 4, 2019, 6:29pm UTC](https://community.auth0.com/t/getting-last-password-reset-value-in-net-core-service/26123/1 "2019-06-04T18:29:55Z")

</div>

In my .Net Core application I override AuthorizeAttribute. In OnAuthorizationAsync method I get the access token, I then call [https://mytenant.auth0.com/userinfo?access\_token=xyz](https://mytenant.auth0.com/userinfo?access_token=xyz) to get user profile. Also when I redirect the user for authentication in my SPA, I use these settings scope: ‘openid last\_password\_reset email profile’. However GET on [https://mytenant.auth0.com/userinfo?access\_token=xyz](https://mytenant.auth0.com/userinfo?access_token=xyz) is failing to return last\_password\_reset value. What am I missing? This is all I am getting

"{"sub":"auth0|5555666666777777","nickname":"authuser2","name":"authuser2@gmail.com","picture":"[https://s.gravatar.com/avatar/xyz?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fra.png\“,\“updated\_at\”:\“2019-06-04T18:25:37.518Z\”,\“email\”:\“authuser2@gmail.com\”,\“email\_verified\”:true}”](https://s.gravatar.com/avatar/xyz?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fra.png%5C%22,%5C%22updated_at%5C%22:%5C%222019-06-04T18:25:37.518Z%5C%22,%5C%22email%5C%22:%5C%22authuser2@gmail.com%5C%22,%5C%22email_verified%5C%22:true%7D%22)

---

<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:** [June 5, 2019, 6:52pm UTC](https://community.auth0.com/t/getting-last-password-reset-value-in-net-core-service/26123/3 "2019-06-05T18:52:56Z")

</div>

Hi @rajaauthowner,

The `/userinfo` endpoint returns a set of standard claims, which doesn’t currently include `last_password_reset`.

It can be obtained through the [Management API /api/v2/users/{id}](https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id) endpoint.

It could also be added to a token as a custom claim in a rule.

> **[Sample Use Cases: Scopes and Claims](https://auth0.com/docs/get-started/apis/scopes/sample-use-cases-scopes-and-claims)**
>
> Learn how to use scopes and claims with applications and APIs.

Hope this helps,

Dan

---

<div class="post-metadata">

**Author:** ![rajaauthowner](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rajaauthowner/32/13366_2.png) [@rajaauthowner](https://community.auth0.com/u/rajaauthowner)\
**Post date:** [June 6, 2019, 2:37pm UTC](https://community.auth0.com/t/getting-last-password-reset-value-in-net-core-service/26123/4 "2019-06-06T14:37:44Z")

</div>

Thanks Dan. I tried creating a machine to machine api and issued the CURL call (the exact command given by Auth0) and I get “{“error”:“access\_denied”,“error\_description”:“Unauthorized”}curl: (6) Could not resolve host: application”

Very frustrating we have to go through so many hoops to get simple things done. Auth0 created a default Test application for access to management API and that is returning “unauthorized” too.

---

<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:** [June 6, 2019, 4:23pm UTC](https://community.auth0.com/t/getting-last-password-reset-value-in-net-core-service/26123/5 "2019-06-06T16:23:38Z")

</div>

@rajaauthowner,

Sorry to hear your frustrations! It’s not a great experience to want to be able to do something and be blocked with errors. I have written a rule that will add a custom claim to your token. This is the easiest way I can think to get you the last pw reset information. **Note: if a user has never reset their password this value will be undefined, and wont show up in a token!**

```auto
function (user, context, callback) {
  const namespace = 'https://myapp.example.com/';
  context.idToken[namespace + 'last_password_reset'] = user.last_password_reset;
  context.accessToken[namespace + 'last_password_reset'] = user.last_password_reset;
  callback(null, user, context);
}

```

I have tested this and it works with a user who has reset their password on an Auth0 DB connection.

If this solution does not accomplish what you want, let me know and we can work through the management API solution.

Thanks,  
Dan

---

<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:** [July 8, 2019, 5:56pm UTC](https://community.auth0.com/t/getting-last-password-reset-value-in-net-core-service/26123/6 "2019-07-08T17:56:28Z")

</div>

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