GitHub Actions OIDC to AWS: Fix "Not Authorized to Perform sts:AssumeRoleWithWebIdentity", "No OpenIDConnect Provider Found", "Incorrect Token Audience" and the July 2026 Immutable sub Claim

Logeshwaran
—

When a GitHub Actions workflow fails with "Not authorized to perform sts:AssumeRoleWithWebIdentity", AWS received GitHub's identity token and your role's trust policy rejected it, almost always because the token's sub (subject) claim does not match the pattern in the policy. The three neighbors have plainer causes: "No OpenIDConnect provider found in your account" means the account has no IAM identity provider for https://token.actions.githubusercontent.com; "Incorrect token audience" means the token's audience is not sts.amazonaws.com; and "Could not load credentials from any providers" usually means the workflow never got a token because permissions: id-token: write is missing. The 2026 twist catches people with policies that worked for years: GitHub repositories created after July 15, 2026, and any repository renamed or transferred after that date, send an "immutable" subject such as repo:octo-org@123456/octo-repo@456789:ref:refs/heads/main, with numeric owner and repository IDs, so a trust policy written for repo:octo-org/octo-repo:* silently stops matching. This page sets the connection up correctly, shows how to print the real claims your workflow sends, and fixes each error.

Jake's shop website deploys from GitHub to an S3 bucket, and for years the workflow used an access key stored as a repository secret. His developer friend Ethan replaced it with OIDC, no stored keys at all, and it worked first time on the old repository. Then, in August, they moved the code to a new repository under the shop's organization, and every deploy failed with "Not authorized to perform sts:AssumeRoleWithWebIdentity". The trust policy said repo:jakes-shop/website:*; the token said repo:jakes-shop@81234567/website@99887766:ref:refs/heads/main. "Same name," Jake said. "Same name," Ethan said, "new passport."

⚡ Quick Answer

• Not authorized: the trust policy's sub condition does not match the token. Print the real claims (one workflow step) and fix the pattern. See your claims.

• New or renamed repo since July 15, 2026: the subject now carries IDs: repo:ORG@ORG-ID/REPO@REPO-ID:.... Update the policy. The change.

• No OpenIDConnect provider found: add the identity provider in this account's IAM. Incorrect token audience: use sts.amazonaws.com. Every error.

• Could not load credentials: add permissions: id-token: write to the job (or workflow). Permissions.

Set it up right · Subject formats · Session length · Troubleshooting.

New to the vocabulary? An IAM role is a set of permissions anything trusted can borrow for a short time; its trust policy is the JSON that says who may borrow it. OIDC (OpenID Connect) lets GitHub vouch for a workflow run with a signed token, so AWS can hand over temporary credentials without any stored key.

🧭 NEW HERE? READ THESE FIRST

New to IAM roles, policies or ARNs? These five pages give you the basics this guide builds on:

💡 Keep the role's trust policy open in another tab; most fixes below are one line in it.

How GitHub Actions OIDC to AWS works, in four steps

  1. Your workflow job, allowed by permissions: id-token: write, asks GitHub for a signed token (a JWT) describing the run: which repository, branch, environment and event.
  2. The aws-actions/configure-aws-credentials action sends that token to AWS STS in an AssumeRoleWithWebIdentity call, naming your role.
  3. STS checks that your account has an identity provider for https://token.actions.githubusercontent.com, that the token's audience is allowed, and that the role's trust policy conditions match the token's claims.
  4. If everything matches, STS returns credentials that last an hour by default, and the following steps run as the role.

Each error on this page is one of those checks failing. Knowing which step failed is most of the fix.

Set it up correctly: provider, role and workflow

1. The identity provider, once per AWS account. In the IAM console, choose Identity providers, Add provider, OpenID Connect; provider URL https://token.actions.githubusercontent.com; audience sts.amazonaws.com. Older guides ask for a certificate thumbprint; the official action's documentation now says a thumbprint, if specified, is ignored. With the AWS CLI:

aws iam create-open-id-connect-provider \
  --url https://token.actions.githubusercontent.com \
  --client-id-list sts.amazonaws.com

2. The role and its trust policy. The trust policy names the provider (its ARN includes your account number) and restricts which repositories and branches may use the role:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com" },
    "Action": "sts:AssumeRoleWithWebIdentity",
    "Condition": {
      "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
      "StringLike": {
        "token.actions.githubusercontent.com:sub": [
          "repo:jakes-shop/website:ref:refs/heads/main",
          "repo:jakes-shop@81234567/website@99887766:ref:refs/heads/main"
        ]
      }
    }
  }]
}

Listing both the name-only and the immutable form, as above, keeps the role working before and after a repository switches format. Attach the permissions the workflow needs (for Jake, writing to one S3 bucket) as a separate permissions policy on the role.

3. The workflow.

permissions:
  id-token: write   # required to request the OIDC token
  contents: read    # required for actions/checkout

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: aws-actions/configure-aws-credentials@v6
        with:
          role-to-assume: arn:aws:iam::111122223333:role/github-deploy
          aws-region: ap-south-1
      - run: aws sts get-caller-identity

The last step is your test: it prints the assumed role's ARN. If it does, the connection works and any later failure is about the role's permissions, not OIDC.

Every GitHub Actions OIDC error, and what it means

ErrorWhich check failedFix
Could not load credentials from any providersStep 1: no token was issued, so the action had nothing to useAdd permissions: id-token: write where the job can see it
No OpenIDConnect provider found in your account for https://token.actions.githubusercontent.comStep 3: the account has no matching identity providerCreate it in the account that owns the role; check the URL has no typo or trailing slash
Incorrect token audienceStep 3: the token's aud is not in the provider's audience listUse sts.amazonaws.com on both sides, or add your custom audience to the provider
Not authorized to perform sts:AssumeRoleWithWebIdentityStep 3: the trust policy did not match (usually sub), or the provider ARN in it is wrongPrint the claims and correct the conditions
The requested DurationSeconds exceeds the MaxSessionDuration set for this roleStep 4: role-duration-seconds is longer than the role allowsRaise the role's maximum session duration, or ask for less

The action wraps the AWS message, so in your log the second-to-last one reads "Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity". The AWS part after the colon is what matters.

See the claims your workflow really sends

Most "Not authorized" failures end the moment you see the token's actual sub. This step prints the useful claims, and only the claims; never print the token itself, which works as a credential for a few minutes:

      - name: Show OIDC claims (debug)
        run: |
          TOKEN=$(curl -sH "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
            "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sts.amazonaws.com" | jq -r .value)
          python3 - "$TOKEN" <<'EOF'
          import sys, json, base64
          p = sys.argv.pop().split(".").pop(1); p += "=" * (-len(p) % 4)
          c = json.loads(base64.urlsafe_b64decode(p))
          print(json.dumps({k: c.get(k) for k in ("sub", "aud", "repository", "ref",
                "environment", "repository_id", "repository_owner_id")}, indent=1))
          EOF
  1. Add the step before the configure step, in a job that has id-token: write.
  2. Run the workflow once and open the step's log.
  3. Compare the printed sub with your trust policy character by character: the organization and repository names (keep the case exactly as it appears in the token), the branch, whether an environment: part replaced the ref: part, and whether @ and numbers appear after the names.
  4. Fix the policy, rerun, and remove the debug step once the deploy is green.

The July 2026 change: immutable subject claims with owner and repository IDs

GitHub changed the default subject format because names can be reused: if an organization or repository is deleted or renamed, someone else can later take the old name and, with a name-only trust policy, receive tokens that look identical. Adding the numeric IDs makes each subject unique for good. The rules, from GitHub's OIDC reference:

  • Repositories created after July 15, 2026 use the immutable format by default: repo:OWNER@OWNER-ID/REPO@REPO-ID:ref:refs/heads/BRANCH.
  • Renaming or transferring a repository after that date also moves it to the immutable format. Jake's "new repository" was exactly this case.
  • Older repositories keep the old format unless an organization or repository owner opts in through the OIDC settings or the REST API.
  • The @ separator was chosen because it cannot appear in GitHub user or repository names. The change applies to github.com, not GitHub Enterprise Server.

To find the IDs for your policy, use the claims step above (repository_owner_id and repository_id), or the GitHub API: gh api repos/OWNER/REPO --jq '.id, .owner.id'. Then update the trust policy. If several repositories use one role, a pattern such as repo:jakes-shop@81234567/* covers every repository of that organization in the new format, and it cannot be satisfied by a different organization that later takes the same name.

Ethan added the new subject next to the old one and the deploy went green on the next push. "And if someone registers jakes-shop after we rename it?" Jake asked. "Then they get the name," Ethan said. "Not the number."

Subject claim formats: branches, environments, pull requests and tags

The job runs forsub claim (name-only format)
A push to a branchrepo:ORG/REPO:ref:refs/heads/BRANCH
A tagrepo:ORG/REPO:ref:refs/tags/TAG
A job that uses a GitHub environmentrepo:ORG/REPO:environment:ENVIRONMENT (replaces the ref)
A pull request (no environment)repo:ORG/REPO:pull_request
Immutable format, any of the aboverepo:ORG@ORG-ID/REPO@REPO-ID: followed by the same ending

The environment row causes a classic failure: a workflow that worked on main stops working the day someone adds environment: production to the job, because the subject changes from ...:ref:refs/heads/main to ...:environment:production. Add the environment form to the policy, which is also the safer pattern: GitHub environments can require approvals before the job runs.

"Could not load credentials from any providers": the token was never issued

Without id-token: write, GitHub issues no OIDC token, the action finds no way to authenticate, and you get the generic credentials error rather than an OIDC one. Three places it goes missing:

  • A permissions block somewhere else. When a workflow or job sets permissions, every permission not listed becomes "none". A job-level block with only contents: read silently removes id-token. List both.
  • Reusable workflows. A called workflow cannot grant itself more than its caller allows; the calling workflow's job must also have id-token: write.
  • Organization defaults. A restrictive default token permission setting does not stop you declaring id-token: write in the workflow, but it does mean you must declare it.

If you still see the error with the permission in place, check that the configure step actually has a role-to-assume (a typo in a secret or variable name gives an empty value). Our "Could not load credentials" guide covers the same message outside GitHub.

Session length, and the hour that ends mid-deploy

The credentials last 1 hour by default; the action accepts role-duration-seconds from 900 (15 minutes) to 43,200 (12 hours). The role caps it: its maximum session duration defaults to 1 hour, and asking for more fails with "The requested DurationSeconds exceeds the MaxSessionDuration set for this role." For a long job, raise the role's maximum (IAM console, the role, Edit, Maximum session duration) and then the action input. If a later step in the same job assumes another role ("role chaining"), that second session is limited to 1 hour regardless; our ExpiredToken guide explains why.

Creating the provider and role with Terraform or CloudFormation

If several repositories or accounts need this, define it as code so the trust policy is reviewed like any other change. In Terraform, the provider is an aws_iam_openid_connect_provider resource with url = "https://token.actions.githubusercontent.com" and client_id_list = ["sts.amazonaws.com"], and the role's assume_role_policy holds the conditions shown above. Two cautions: an account can have only one provider per URL, so a second stack that tries to create it again fails (import or reference the existing one); and when you edit the sub list, keep the old form until every repository has switched, or you will lock out the ones that have not.

GitHub Actions OIDC still failing? Troubleshooting by symptom

"Not authorized to perform sts:AssumeRoleWithWebIdentity" on a new or renamed repository

The repository sends the immutable subject with owner and repository IDs. Add the repo:ORG@ORG-ID/REPO@REPO-ID form to the trust policy's sub condition.

Works on main, fails on other branches or pull requests

The sub condition names only refs/heads/main. Add the other branches, the pull_request form, or a wider pattern if those runs should deploy at all.

Stopped working after adding an environment to the job

The subject changed to repo:ORG/REPO:environment:NAME. Add that form to the trust policy.

Works in one AWS account, fails in another

Each account needs its own identity provider, and each role's trust policy must name the provider ARN in its own account. Copying a policy between accounts without changing the account number fails.

"No OpenIDConnect provider found" although the provider exists

The role is in a different account from the provider, or the provider URL differs (a trailing slash, http instead of https). The URL must be exactly https://token.actions.githubusercontent.com.

"Incorrect token audience" after setting a custom audience

The audience input in the workflow must also be in the provider's audience list. Use the default sts.amazonaws.com unless you have a reason not to.

Fails only for pull requests from forks

GitHub limits what workflows from forked repositories can do with tokens and secrets. Deploy from pushes or after review instead of from fork pull requests.

AccessDenied on later steps, after the role was assumed

OIDC worked; the role's permissions policy lacks the action. Read the denied action from the error and add it to the role's permissions, not the trust policy.

GitHub Actions OIDC with AWS: frequently asked questions

What does "Not authorized to perform sts:AssumeRoleWithWebIdentity" mean?

AWS received GitHub's token, but the role's trust policy rejected it, usually because the token's sub claim does not match the policy's pattern. Print the token's claims in the workflow and update the condition.

How do I fix "No OpenIDConnect provider found in your account"?

Create an IAM OpenID Connect identity provider in the same account as the role, with URL https://token.actions.githubusercontent.com and audience sts.amazonaws.com.

What should the audience be for GitHub Actions and AWS?

sts.amazonaws.com, which is what the official configure-aws-credentials action requests by default. Set a custom audience only if you also add it to the provider's audience list.

Why does configure-aws-credentials say "Could not load credentials from any providers"?

Usually the job lacks permissions: id-token: write, so no OIDC token was issued. Add it to the job or workflow permissions, and to the caller of any reusable workflow.

What is the GitHub OIDC sub claim?

The subject that identifies the run, such as repo:ORG/REPO:ref:refs/heads/main, repo:ORG/REPO:environment:NAME or repo:ORG/REPO:pull_request. AWS trust policies match on it to decide which workflows may assume a role.

What is the immutable subject claim in GitHub Actions?

A subject format that includes numeric IDs, repo:OWNER@OWNER-ID/REPO@REPO-ID:..., so a reused name cannot produce the same subject. It is the default for repositories created, renamed or transferred after July 15, 2026.

How do I find my GitHub repository ID and owner ID?

Run gh api repos/OWNER/REPO --jq '.id, .owner.id', or read repository_id and repository_owner_id from the OIDC token's claims in a workflow step.

Do I still need a thumbprint for the GitHub OIDC provider?

No. The official action's documentation says a thumbprint, if specified, is ignored. Older guides that compute one are out of date.

Can one IAM role serve several GitHub repositories?

Yes. List each repository's subject in the sub condition, or use a StringLike pattern scoped to your organization, preferably in the immutable form so it cannot match a different owner with the same name.

How long do GitHub Actions OIDC credentials last?

One hour by default. The action accepts 15 minutes to 12 hours through role-duration-seconds, but the role's maximum session duration, which defaults to one hour, must allow it.

Should I use StringEquals or StringLike for the sub condition?

StringEquals for exact subjects, StringLike when the value contains wildcards such as repo:ORG/REPO:*. Wildcards are convenient but broad; scope them as narrowly as your workflows allow.

Why does adding an environment break OIDC?

When a job uses a GitHub environment, the subject becomes repo:ORG/REPO:environment:NAME instead of the branch form. Add the environment subject to the trust policy.

Is OIDC safer than storing AWS access keys in GitHub secrets?

Yes. No long-lived key exists to leak; each run gets credentials that expire within hours, limited by a trust policy to the repositories and branches you choose.

Can I use GitHub OIDC with Terraform?

Yes. Run configure-aws-credentials before Terraform in the job, or let the Terraform AWS provider assume the role with web identity. Define the provider and role themselves in Terraform for repeatability.

Does the GitHub OIDC change affect GitHub Enterprise Server?

No. The immutable subject format applies to github.com; GitHub Enterprise Server is not part of the change.

Why does my workflow work for pushes but not pull requests?

Pull request runs send the subject repo:ORG/REPO:pull_request, which a branch-only condition does not match. Add it if pull requests should have access, and keep fork pull requests away from deploy roles.

For readers preparing for an AWS certification

We have been covering AWS certifications alongside our fixes, so here is a short extra for readers studying for one. If you only came for the fix, you already have it; feel free to skip this part.

Exams that test this topic: Security – Specialty (SCS-C03) • DevOps Engineer – Professional (DOP-C02) • Developer – Associate (DVA-C03 from December 1, 2026).

Here are the exam-style questions this topic tends to raise, with the reasoning you need to answer them:

1. A CI/CD pipeline in GitHub Actions must deploy to AWS without stored access keys. What is the recommended approach?

An IAM OIDC identity provider for token.actions.githubusercontent.com and an IAM role whose trust policy allows sts:AssumeRoleWithWebIdentity for that repository.

2. How do you restrict a role so only the main branch of one repository can assume it?

A trust policy condition on token.actions.githubusercontent.com:sub matching that repository and ref:refs/heads/main, plus aud equal to sts.amazonaws.com.

3. The workflow fails with "No OpenIDConnect provider found in your account". What is missing?

The IAM identity provider for https://token.actions.githubusercontent.com in the account that owns the role.

4. Assuming the role fails with "Not authorized to perform sts:AssumeRoleWithWebIdentity". Where do you look first?

The role trust policy conditions, especially the sub claim, compared with the token the workflow actually sends.

5. Which workflow permission is required for the job to request an OIDC token?

id-token: write.

6. Why is OIDC federation more secure than storing an IAM user access key in CI secrets?

No long-lived credential exists to leak; each run gets temporary credentials limited by the trust policy and the role session duration.

Exam codes and dates change often. Our AWS certification changes page keeps track of what is current.

Jake's deploys have run green since, from the new repository, with no key stored anywhere. The old access key, the one that started all this, was deactivated the same afternoon and deleted a week later. "So GitHub proves who it is, and AWS checks the passport," Jake summarized. "Including the number on it," Ethan said, "since July."

📌 If you keep one line from this page

Give the job id-token: write, use audience sts.amazonaws.com, print the token's sub, and make the trust policy match it, including the repo:ORG@ORG-ID/REPO@REPO-ID form that new, renamed and transferred repositories have sent since July 15, 2026.

Provider URL https://token.actions.githubusercontent.com · no thumbprint needed · 1-hour default session.

Revision note. Written October 22, 2026, covering the immutable subject claim format GitHub made the default for new repositories on July 15, 2026. "Trust, but verify," the proverb says; print the claims before you edit the policy.

Related