Skip to content

app_auth credentials expire after an hour #977

Closed

Description

@jcogilvie

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

0.13.5

Affected Resource(s)

All github resources that require authentication.

Terraform Configuration Files

provider "github" {
  owner = "MyOrg"
  app_auth {
     # correct values are set on the command line
  }
}

Debug Output

Mon, 15 Nov 2021 00:50:18 GMT
/home/runner/work/_temp/82078d0e-8462-4088-a73b-519aff5c7a56/terraform-bin refresh --parallelism 50
Mon, 15 Nov 2021 00:50:46 GMT
module.my_module.data.github_team.core: Refreshing state... [id=...34]
[...many successful objects being refreshed...]
Mon, 15 Nov 2021 01:50:48 GMT
aws_iam_user_policy.tf_user: Refreshing state... [id=my-repo:state-access]
Mon, 15 Nov 2021 01:50:48 GMT
Error: GET https://api.github.com/repos/MyOrg/my-repo: 403 API rate limit of 60 still exceeded until 2021-11-15 02:50:44 +0000 UTC, not making remote request. [rate reset in 59m57s]

Panic Output

None

Expected Behavior

Authentication should be valid for as long as it takes terraform to run.

Actual Behavior

Credentials time out after an hour. Installation Access Tokens are valid for exactly one hour:

Installation access tokens have the permissions configured by the GitHub App and expire after one hour.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform refresh

Important Factoids

We have a very large set of repositories managed by the github provider. In attempting to switch from OAuth token authentication to GH Apps authentication, we have discovered that after approximately an hour (+ a few seconds usually) we start getting 403s to resources that are expressily allowed by our GH App permissions.

Activity

  1. added
    Type: Bug
    on Dec 30, 2021
  2. github-actions commented on Nov 30, 2022

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  3. added
    Status: Stale
    and removed on Nov 30, 2022
  4. added
    Status: Up for grabs
    Status: Pinned
    and removed
    Status: Stale
    on Dec 1, 2022
  5. kfcampbell commented on Dec 1, 2022

    @kfcampbell
    Contributor

    Pinning this issue as I believe it's still important and relevant.

  6. x-yuri commented on Jun 20, 2023

    @x-yuri

    @jcogilvie The link you provided doesn't have that phrase. It was probably moved here. But it looks like they're talking about access tokens which supposedly have nothing to do with it. If I understand you correctly, for an hour terraform invocations succeed, after an hour they stop succeeding. Also the debug output ends with a rate limit error message. Which supposedly means that the issue is not with expiration.

    On the other hand I do seem to experience expiration issues. Here's a brief explanation of how I gave terraform access to GitHub. That is, it's about making API request, but in case of terraform you probably don't need to obtain an access token. And you certainly don't need to make API requests. But AFAICS you need to activate a device at https://github.com/login/device Whatever that means. And I guess that's the thing that expires in my case. I'm not exactly sure, but I'm going to confirm it in the near future.

    Which brings up the question, did you not need to activate a device to make it work in the first place?

  7. jcogilvie commented on Jun 20, 2023

    @jcogilvie
    Author

    My issue is specific to logging in as an app installation with the GitHub App app_auth field of the provider, given an app ID, an app installation ID, and a PEM file.

    I can't speak to the internal workings of the provider, but it's more than likely that it exchanges those credentials for a token that's valid for an hour.

  8. 22 remaining items

  9. benjaminlukeclark commented on Dec 17, 2025

    @benjaminlukeclark

    Commenting on here.

    If you're using terraform to manage GitHub at an enterprise scale you do run into this quite frequently.

  10. removed
    Type: Bug
    on Feb 11, 2026
  11. deiga commented on Apr 19, 2026

    @deiga
    Collaborator
  12. removed
    Status: Up for grabs
    on May 22, 2026
  13. moved this from Backlog to In Progress in Terraform Provideron Jun 15, 2026
  14. yashrajdighe commented on Jun 15, 2026

    @yashrajdighe

    Raised a PR to fix this issue: #3489

  15. deiga commented on Jul 22, 2026

    @deiga
    Collaborator

    Resolved with the new client implementation. Use it with legacy_client = false

  16. moved this from In Progress to Done in Terraform Provideron Jul 22, 2026
  17. moved this from Done to In Progress in Terraform Provideron Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AuthenticationProviderStatus: Pinnedp/app_authvNext

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions