# "token expiration" for M2M authentication with Terraform?

**URL:** <https://community.auth0.com/t/token-expiration-for-m2m-authentication-with-terraform/115103>\
**Category:** Get Help\
**Tags:** clients, management-api\
**Created:** [August 31, 2023, 8:42am UTC](https://community.auth0.com/t/token-expiration-for-m2m-authentication-with-terraform/115103 "2023-08-31T08:42:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![frederic.triquet](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/frederic.triquet/32/33838_2.png) [@frederic.triquet](https://community.auth0.com/u/frederic.triquet)\
**Post date:** [August 31, 2023, 8:42am UTC](https://community.auth0.com/t/token-expiration-for-m2m-authentication-with-terraform/115103/1 "2023-08-31T08:42:10Z")

</div>

Hi everyone,

I have read many posts about API authentication and people having issues when configuring M2M token lifetime.

Thanks to these posts, I have found a way to configure it:

1. go to “Applications → APIs → the specific API → settings → Token Settings”

2. set the “Token Expiration” parameter

This may look dumb to list those steps here, but I spent quite some time figuring them out.

What I was doing instead was:

1. “Applications → Applications → the corresponding Machine to Machine application → Settings → ID Token”

2. Set the ID Token Expiration

This second parameter is not the one I wanted to set (for dev purposes, I wanted to set a very short token lifetime, so I could verify my token renewal code was OK).

I am using Terraform with the official auth0 module.

When configuring a `auth0_client`, the `jwt_configuration` bloc sets the ID Token Expiration (the second one).

My questions:

- Using Terraform, how can I configure the “correct” token lifetime (by “correct” I mean “the one I mentioned first”)?

- (bonus) I’d like to understand the difference between those two tokens (I have read that one is an ID Token and the other one is an Access Token… well that doesn’t bring much light to me)

Best regards

Fred

PS: BTW why can’t I set the tags I want for this post like “m2m” and “token-expiration” as I can see on some posts?

---

<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:** [August 31, 2023, 6:35pm UTC](https://community.auth0.com/t/token-expiration-for-m2m-authentication-with-terraform/115103/3 "2023-08-31T18:35:23Z")

</div>

Hey there @frederic.triquet welcome back to the community!

> [@frederic.triquet](#):
>
> Using Terraform, how can I configure the “correct” token lifetime (by “correct” I mean “the one I mentioned first”)?

You’ll want to use the `auth0_resource_server` [resource](https://registry.terraform.io/providers/auth0/auth0/latest/docs/resources/resource_server) - Specifically `token_lifetime`.

> [@frederic.triquet](#):
>
> (bonus) I’d like to understand the difference between those two tokens (I have read that one is an ID Token and the other one is an Access Token… well that doesn’t bring much light to me)

The easiest way to think about this is that ID tokens are tied to _authentication_ (who you are) whereas access tokens are tied to _authorization_ (allow access to a resource). Here’s a great [video](https://www.youtube.com/watch?v=vVM1Tpu9QB4) and corresponding [blog](https://auth0.com/blog/id-token-access-token-what-is-the-difference/) that do a great job explaining the two.

FWIW, there is no reason for an ID token to be involved in your use case and you can pretty much ignore the ID token lifetime altogether.

---

<div class="post-metadata">

**Author:** ![frederic.triquet](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/frederic.triquet/32/33838_2.png) [@frederic.triquet](https://community.auth0.com/u/frederic.triquet)\
**Post date:** [September 4, 2023, 8:37am UTC](https://community.auth0.com/t/token-expiration-for-m2m-authentication-with-terraform/115103/4 "2023-09-04T08:37:27Z")

</div>

Thanks a lot, that is a perfect answer.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 8, 2023, 7:07am UTC](https://community.auth0.com/t/token-expiration-for-m2m-authentication-with-terraform/115103/5 "2023-09-08T07:07:23Z")

</div>

Hey there everyone! 👋🏼

I thought I’m gonna chime in with something that might be of your interest! We’re hosting an Ask Me Anything Session in our Forum regarding Auth0 Terraform Provider.

It’s gonna be on Thursday, September 28, 2023. Check out more info about it here!

> [@Auth0 Community Ask Me Anything with Auth0 Terraform Provider](https://community.auth0.com/t/ask-me-anything-with-auth0-terraform-provider/115670):
>
> Auth0 by Okta Community Ask Me Anything with Auth0 Terraform Provider The Auth0 Community is excited to invite you to our next interactive online Ask Me Anything (AMA) session on Thursday, September 28, 2023, featuring the Auth0 Terraform Provider Product Team. Did you know that the Auth0 Terraform Provider offers a streamlined way to manage Auth0 configurations using Infrastructure as code, allowing for easy version control, automation, and integration into existing DevOps pipelines? No matter…

---

<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:** [September 22, 2023, 7:08am UTC](https://community.auth0.com/t/token-expiration-for-m2m-authentication-with-terraform/115103/6 "2023-09-22T07:08:04Z")

</div>

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