Skip to content

Commit c7c9f62

Browse files
feat: update docs for fine-grained-access tokens (#1025)
Closes SRCH-1751 --------- Co-authored-by: Maedah Batool <[email protected]>
1 parent dae6c38 commit c7c9f62

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

docs/batch-changes/configuring-credentials.mdx

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,70 @@ Let's learn how you can do it for different code hosts.
101101

102102
### GitHub
103103

104-
On GitHub.com, [create a personal access token (classic) with the correct scopes](https://github.com/settings/tokens/new?scopes=repo,read:org,user:email,read:discussion,workflow).
104+
On GitHub.com, create a personal access token or fine-grained access token with the correct scopes.
105105

106106
The `workflow` scope is technically only required if your batch changes modify files in the `.github` directory of a repository. Still, it's recommended to enable it regardless to avoid confusing errors at a later time.
107107

108108
When working with organizations that have SAML SSO (Single Sign On) enabled, configuring credentials requires an additional step that [involves white-listing the token for use in that organization](https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on).
109109

110-
<Callout type="info">At present, only classic personal access tokens (PATs) are supported. Alternative token types like OAuth access tokens (e.g., OAuth apps), and fine-grained personal access tokens (PATv2) are not supported.</Callout>
110+
<Callout type="info">Currently, classic and fine-grained access tokens are supported only. Alternative token types like OAuth access tokens (for example, OAuth apps) are not supported.</Callout>
111+
112+
#### Personal Access Token
113+
114+
Personal access tokens will have access to all repositories you have access to.
115+
116+
[Click here to prefill the form](https://github.com/settings/tokens/new?scopes=repo,read:org,user:email,read:discussion,workflow).
117+
118+
Required Scopes:
119+
120+
- `repo`
121+
- `read:org`
122+
- `user:email`
123+
- `read:discussion`
124+
- `workflow`
125+
126+
#### Fine-Grained Access Token
127+
128+
Fine-grained access tokens allow more granular control of what actions can be performed for a given set of repositories. Most notably, fine-grained access tokens don't grant access by default to all repositories you have access to.
129+
130+
In contrast to personal access tokens, fine-grained access tokens for organization resources may be restricted, may have an expiration, and may require approval.
131+
132+
- **Restriction**: If an administrator of your GitHub organization has restricted access via fine-grained access tokens, you may not be able to use them for Batch Changes
133+
- **Expiration**: If your organization has configured fine-grained access tokens to have maximum lifetimes, you may need to recreate the token when it has expired
134+
- **Approval**: If your organization has configured fine-grained access tokens to require approval, you may need to wait for an administrator to approve the token before you can use it with Batch Changes
135+
136+
Start by navigating to create a [new fine-grained access token](https://github.com/settings/personal-access-tokens/new).
137+
138+
Pick the resource owner that owns the repositories you want to use with Batch Changes. This will likely be your company's GitHub organization.
139+
140+
![Select resource owner for fine-grained access token](https://storage.googleapis.com/sourcegraph-assets/docs/images/batch_changes/2025/fine_grained_select_owner.png)
141+
142+
Scroll down and select "All repositories" so that your token can access all current and future repositories that you have access to. You may restrict it to "Only select repositories", but you may have to generate a new token when you want to handle a new repository with Batch Changes.
143+
144+
![Select all repositories for repository access](https://storage.googleapis.com/sourcegraph-assets/docs/images/batch_changes/2025/fine_grained_select_repos.png)
145+
146+
Under "Permissions," click on the arrows on the right-hand side to expand the list of repository and organization permissions.
147+
148+
![Expand the repository permissions by clicking on the arrows](https://storage.googleapis.com/sourcegraph-assets/docs/images/batch_changes/2025/fine_grained_expand_permissions.png)
149+
150+
Under "Repository permissions", select the following permissions:
151+
152+
- Contents: Read and write
153+
- Metadata: Read-only
154+
- Pull requests: Read and write
155+
- Workflows: Read and write
156+
157+
Under "Organization permissions", select the following permissions:
158+
159+
- Custom properties: Read-only
160+
161+
Once you created the token, copy it and add it to your Batch Changes credentials.
162+
163+
![Add credential modal with fine-grained token selected](https://storage.googleapis.com/sourcegraph-assets/docs/images/batch_changes/2025/setup_fine_grained_access_token.png)
164+
165+
If your organization requires approval for fine-grained access tokens, you must wait for an administrator to approve the token before you can publish changesets with it.
166+
167+
The fine-grained access token is now ready to use. Create a new batch change to start using it.
111168

112169
### GitHub Enterprise
113170

@@ -129,7 +186,7 @@ When working with organizations that have SAML SSO (Single Sign On) enabled, con
129186

130187
<Callout type="warning">Currently, for customers on an instance of GitHub Enterprise Cloud that uses [SSH certificate authorities](https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-git-access-to-your-organizations-repositories/about-ssh-certificate-authorities) and requires SSH certificates to authenticate, we are unable to provide a means of authenticating Batch Changes to your code host.</Callout>
131188

132-
<Callout type="info">At present, only classic personal access tokens (PATs) are supported. Alternative token types like OAuth access tokens (e.g. OAuth apps), and fine-grained personal access tokens (PATv2) are not supported.</Callout>
189+
<Callout type="info">Currently, classic personal and fine-grained access tokens are supported only. Alternative token types like OAuth access tokens (for example, OAuth apps) are not supported.</Callout>
133190

134191
### GitLab
135192

@@ -239,4 +296,4 @@ To remove a GitHub app from your Sourcegraph instance, navigate back to the same
239296
<source src="https://sourcegraphstatic.com/docs/videos/batch_changes/2024/batches-github-app-delete.mp4" type="video/mp4" />
240297
</video>
241298

242-
If you want to delete the GitHub app entirely you have to navigate to [GitHub's list of applications](https://github.com/settings/apps/), and delete it from there.
299+
If you want to delete the GitHub app entirely, you have to navigate to [GitHub's list of applications](https://github.com/settings/apps/) and delete it from there.

0 commit comments

Comments
 (0)