# Call limit on openid configuration

**URL:** <https://community.auth0.com/t/call-limit-on-openid-configuration/122444>\
**Category:** Get Help\
**Tags:** keys, management-api\
**Created:** [December 6, 2023, 1:54pm UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444 "2023-12-06T13:54:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnthonyDaSilva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anthonydasilva/32/33385_2.png) [@AnthonyDaSilva](https://community.auth0.com/u/AnthonyDaSilva)\
**Post date:** [December 6, 2023, 1:54pm UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/1 "2023-12-06T13:54:20Z")

</div>

For legacy reasons, we have to check the token validity/signature etc at each call.  
In some cases, the call to /.well-known/openid-configuration is rejecting due to several calls at the same time.

I made something like this to reduce the number of calls:

```
                if (KeyResolver == null)
                {
                    KeyResolver = new OpenIdConnectSigningKeyResolver(domain);
                }

                var tokenParams = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
                {
                    ValidAudience = ApplicationConfig.Audience,
                    ValidateIssuer = true,
                    ValidateIssuerSigningKey = true,
                    ValidateLifetime = true,
                    ValidateAudience = true,
                    ValidIssuer = domain,
                    RequireSignedTokens = true,
                    IssuerSigningKeyResolver = (token, securityToken, kid, parameters) => KeyResolver.GetSigningKey(kid)
                };

```

Is it the proper way to do it? Should I keep the key only for a certain amount of time before retrieving it again?

Thanks

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 7, 2023, 12:50am UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/3 "2023-12-07T00:50:56Z")

</div>

Hey there @AnthonyDaSilva !

> [@AnthonyDaSilva](#):
>
> Is it the proper way to do it? Should I keep the key only for a certain amount of time before retrieving it again?

Is there any way you can cache the information retrieved from `/.well-known/openid-configuration ` and only make a call to the endpoint when needed?

---

<div class="post-metadata">

**Author:** ![AnthonyDaSilva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anthonydasilva/32/33385_2.png) [@AnthonyDaSilva](https://community.auth0.com/u/AnthonyDaSilva)\
**Post date:** [December 7, 2023, 5:46am UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/4 "2023-12-07T05:46:47Z")

</div>

Hey tyf,

That’s more or less what I implemented above but I was wondering if I need to put a validity date on the data retrieved from `/.well-known/openid-configuration` or will it always be the same ?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 8, 2023, 11:36pm UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/5 "2023-12-08T23:36:47Z")

</div>

> [@AnthonyDaSilva](#):
>
> I was wondering if I need to put a validity date on the data retrieved from `/.well-known/openid-configuration` or will it always be the same ?

The data retrieved is certainly subject to change, but it shouldn’t be often at all - It really just depends on if you are making changes to your tenant that will affect this information. I would say fetching once a day or less should be sufficient. You could also look into configuring some logic to request when your app experiences a failure that could be related to this configuration.

---

<div class="post-metadata">

**Author:** ![AnthonyDaSilva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anthonydasilva/32/33385_2.png) [@AnthonyDaSilva](https://community.auth0.com/u/AnthonyDaSilva)\
**Post date:** [December 11, 2023, 7:53am UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/6 "2023-12-11T07:53:39Z")

</div>

Hey @ty.frith,

Thanks for your answer, it seems to work for now.

Kind Regards,

Anthony

---

<div class="post-metadata">

**Author:** ![AnthonyDaSilva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anthonydasilva/32/33385_2.png) [@AnthonyDaSilva](https://community.auth0.com/u/AnthonyDaSilva)\
**Post date:** [December 11, 2023, 8:24am UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/7 "2023-12-11T08:24:01Z")

</div>

Hi @ty.frith,

For this part:

> You could also look into configuring some logic to request when your app experiences a failure that could be related to this configuration.

How do you reckon I should proceed?

Regards

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 11, 2023, 10:39pm UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/8 "2023-12-11T22:39:15Z")

</div>

Hey @AnthonyDaSilva !

This isn’t an exhaustive list but I might look out for token validation errors, authentication request issues, token refresh errors, userinfo endpoint access, response/grant type errors, etc. Basically anything that might fail as a result of changes made to the discovery endpoint. If your app begins experiencing unexpected issues, it might be due to the need to refresh discovery data you’ve cached. That being said, I’d expect changes to be infrequent under normal circumstances.

---

<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:** [December 25, 2023, 10:39pm UTC](https://community.auth0.com/t/call-limit-on-openid-configuration/122444/9 "2023-12-25T22:39:53Z")

</div>

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