OIDC for Bitrise
Create an Open ID Connect (OIDC) trust policy and send an OIDC token with app.bitrise.io as the audience for an OIDC credential exchange. This allows third-party services to authenticate to your Bitrise workspace and access Bitrise resources.
For more information on how OIDC works, see Authentication to Bitrise with OIDC.
Creating a trust policy on BitriseClick to copy link
Create an OIDC trust policy to grant external services access to Bitrise resources via an OIDC token exchange.
To authenticate the Bitrise Build Cache in a GitHub Actions workflow, you don't need to create the policy manually. Bitrise creates it for you when you add a new Build Cache connection. For more information, see the Authentication section of the GitHub Actions guide for your build tool, for example Gradle.
-
Log in to Bitrise and hover over the left navigation bar.
-
Make sure you have the right workspace selected in the Workspace menu.
-
Select Settings.
-
Select Security and then go to the OIDC trust policies tab.

-
Click New OIDC policy.
-
Fill out the policy details:
- Policy name: The policy identifier.
- Issuer (iss): The HTTPS URLs for identity providers that Bitrise will trust.
- Session duration: How long the token will be valid.

-
On the next page, set matching rules in a JSON format.
Matching rules define which claims Bitrise must see in the token to match the trust policy.
importantYou must have at least one matching rule. The
subclaim is mandatory: it identifies the subject that triggered the token exchange.For example, you can create matching rules for a specific branch of a repository and name a Workflow:
{"sub": "repo:my-org/my-repo:environment:prod","workflow": "CI","ref": "refs/heads/main","repository": "my-org/my-repo"}To match several values or a pattern, see Writing matching rules.
-
On the next page, set up a workspace role for the short-lived token.
The workspace role determines the access level of the token. Read more: Roles and permissions in workspaces.
-
On the next page, configure product access. Grant full admin access to all products, or grant granular access to either Bitrise CI or Release Management or both:
-
Select Admin access to grant admin access to all projects owned by the workspace.
-
Select Bitrise CI and/or then select the projects or Release Management apps and access roles for the token. It can have different levels of access on different projects!
Read more: Roles and permissions for Bitrise CI
-
Select Release Management then select the Release Management apps and access roles for the token. It can have different access levels on different Release Management apps.
Read more: Release Management roles and permissions
-
-
When ready, click Create policy.
Writing matching rulesClick to copy link
Each rule matches one claim in the token. A token matches the policy only if all rules match.
The examples below use the GitHub sub format without owner and repository IDs. For the format with IDs, and for GitLab and Bitbucket, see Examples by provider.
Exact valueClick to copy link
Matches only this value. This one accepts jobs from my-org/my-repo on the main branch:
{ "sub": "repo:my-org/my-repo:ref:refs/heads/main" }
Any of several valuesClick to copy link
Matches if the claim equals any value in the list. This one accepts the main and release branches:
{
"sub": [
"repo:my-org/my-repo:ref:refs/heads/main",
"repo:my-org/my-repo:ref:refs/heads/release"
]
}
PatternClick to copy link
Matches every value that fits the pattern, where * stands for any text. This one accepts every repository in my-org, on any branch:
{ "sub": { "glob": "repo:my-org/*" } }
A pattern can also be a list, and * can sit in the middle of a value. This one accepts pull request jobs and main branch jobs from every repository in my-org:
{
"sub": {
"glob": [
"repo:my-org/*:pull_request",
"repo:my-org/*:ref:refs/heads/main"
]
}
}
A pattern needs fixed text before the *. A pattern that's only * is rejected, because it would match every token.
Names can be registered again: if an account, repository, or project is renamed or deleted, someone else can take the old name. IDs never change. For a stricter policy, also add a rule for an ID claim, such as repository_owner_id or repository_id for GitHub, or namespace_id or project_id for GitLab.
Examples by providerClick to copy link
Each provider writes sub differently:
| Provider | sub format |
|---|---|
| GitHub Actions | repo:<owner>/<repo>:ref:<ref> |
| GitLab CI | project_path:<group>/<project>:ref_type:<type>:ref:<branch> |
| Bitbucket Pipelines | {<repositoryUuid>}:{<stepUuid>} |
GitHubClick to copy link
Matches jobs from one repository, on the main branch only:
{ "sub": "repo:my-org@123456/my-repo@456789:ref:refs/heads/main" }
Repositories created after July 15, 2026 include the owner and repository IDs in sub. Older repositories keep the previous format unless you opt in to the new one on GitHub. The previous format has no IDs:
{ "sub": "repo:my-org/my-repo:ref:refs/heads/main" }
If you rename or transfer a repository, its sub changes to the new format. Update your policy, or the token exchange fails. For details, see Immutable subject claims in the GitHub documentation. To see the exact sub in your token, see Debugging your OIDC claims on the same page.
For all claims, see OpenID Connect reference in the GitHub documentation.
GitLabClick to copy link
Matches jobs from one project, on the main branch only:
{ "sub": "project_path:my-group/my-project:ref_type:branch:ref:main" }
For all claims, see Token payload in the GitLab documentation.
BitbucketClick to copy link
Matches jobs from one repository, on the main branch only. Bitbucket identifies repositories by UUID, written in braces. When a step uses a deployment environment, sub has the environment UUID in the middle: {<repositoryUuid>}:{<environmentUuid>}:{<stepUuid>}. The pattern below matches both forms.
{
"sub": { "glob": "{11111111-2222-3333-4444-555555555555}:*" },
"branchName": "main"
}
For all claims, see Integrate Pipelines with resource servers using OIDC in the Bitbucket documentation.
Crafting a token requestClick to copy link
After you create at least one trust policy on Bitrise, you can create OIDC token exchange requests to receive short-lived tokens from Bitrise.
-
Get an OIDC token from the service you want to authenticate to Bitrise.
The exact method of getting the token depends on the service. For example: Request a token from GitHub Actions.
-
Use the token in the exchange request to Bitrise.
The request must contain the policy ID and it must be submitted to
app.bitrise.io.curl -i -X POST https://app.bitrise.io/oidc/token \-H "Content-Type: application/x-www-form-urlencoded" \-d "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \-d "subject_token_type=id_token" \-d "policy_id=<POLICY_UUID>" \-d "subject_token=<OIDC_TOKEN>"You can also send a request as
application/json:curl -i -X POST https://app.bitrise.io/oidc/token \-H "Content-Type: application/json" \-d"{ \"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\",\"subject_token_type\": \"id_token\",\"subject_token\": <OIDC_TOKEN>,\"policy_id\": <POLICY_ID> }"
ResponseClick to copy link
A successful request returns the short-lived Bitrise token in access_token:
{
"access_token": "<BITRISE_WAT_TOKEN>",
"token_type": "bearer",
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
"expires_in": 3600
}
Use the access_token value to authenticate your requests to the Bitrise API: send it in the Authorization header, as described in Authenticating with the Bitrise API. The token expires after the session duration set in the policy.