# Caching login credentials for provider

**URL:** <https://discuss.hashicorp.com/t/caching-login-credentials-for-provider/57685>\
**Category:** Terraform Providers\
**Created:** [August 27, 2023, 12:34pm UTC](https://discuss.hashicorp.com/t/caching-login-credentials-for-provider/57685 "2023-08-27T12:34:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lesteenman](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/lesteenman/32/35998_2.png) [@lesteenman](https://discuss.hashicorp.com/u/lesteenman)\
**Post date:** [August 27, 2023, 12:34pm UTC](https://discuss.hashicorp.com/t/caching-login-credentials-for-provider/57685/1 "2023-08-27T12:34:19Z")

</div>

I’m writing a provider for an internally used tool, which does not allow more than a handful of logins every two minutes. Is there a way to cache the requested login token between Terraform runs?

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [August 27, 2023, 6:06pm UTC](https://discuss.hashicorp.com/t/caching-login-credentials-for-provider/57685/2 "2023-08-27T18:06:33Z")

</div>

Terraform providers are just programs like any other - if you want to implement caching of login tokens in a file on disk, you can - just make sure to set appropriately secure file permissions, and only use tokens from the cache when the Terraform configuration really is specifying the same original credentials as were used to acquire the cached token. Terraform itself doesn’t have any special support for this, it would all be code you write yourself in your provider.

---

<div class="post-metadata">

**Author:** ![lesteenman](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/lesteenman/32/35998_2.png) [@lesteenman](https://discuss.hashicorp.com/u/lesteenman)\
**Post date:** [August 28, 2023, 10:03am UTC](https://discuss.hashicorp.com/t/caching-login-credentials-for-provider/57685/3 "2023-08-28T10:03:35Z")

</div>

That makes a lot of sense, actually. What I need to figure out, in that case, is what a sensible place to store information like this is…

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [August 28, 2023, 1:06pm UTC](https://discuss.hashicorp.com/t/caching-login-credentials-for-provider/57685/4 "2023-08-28T13:06:38Z")

</div>

A file in the home directory of the OS user invoking your provider, is the only realistic cross-platform case, short of using OS-specific secrets stores.
