You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively, you can use [Bitbucket Server OAuth](#bitbucket-server-oauth) to authenticate without manually creating a token.
262
+
261
263
### Bitbucket Cloud
262
264
263
265
On Bitbucket, follow the steps to [create an app password](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/). Batch Changes requires the following scopes:
@@ -270,6 +272,8 @@ On Bitbucket, follow the steps to [create an app password](https://support.atlas
Alternatively, you can use [Bitbucket Cloud OAuth](#bitbucket-cloud-oauth) to authenticate without manually creating an app password.
276
+
273
277
### Azure DevOps
274
278
275
279
Follow the steps to [create a PAT](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows#create-a-pat) on Azure DevOps. Batch Changes requires the following scopes:
@@ -373,3 +377,90 @@ To remove a GitHub app from your Sourcegraph instance, navigate back to the same
373
377
</video>
374
378
375
379
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.
380
+
381
+
## Bitbucket OAuth
382
+
383
+
Sourcegraph supports OAuth-based authentication for Batch Changes with both Bitbucket Server (Data Center) and Bitbucket Cloud. This allows users to authorize Batch Changes to act on their behalf using OAuth instead of manually creating personal access tokens or app passwords.
384
+
385
+
<Callouttype="note">
386
+
Bitbucket OAuth for Batch Changes requires a site administrator to first configure a Bitbucket
387
+
[authentication provider](/admin/auth) in Sourcegraph. The same auth provider used for SSO sign-in
388
+
is reused for Batch Changes — no additional provider configuration is needed.
389
+
</Callout>
390
+
391
+
### Bitbucket Server OAuth
392
+
393
+
#### Prerequisites
394
+
395
+
A Sourcegraph site administrator must configure a [Bitbucket Server authentication provider](/admin/auth#bitbucket-server). If your instance already uses Bitbucket Server for sign-in, this step is already complete.
396
+
397
+
The OAuth consumer in Bitbucket Server should be configured as an incoming application link with at minimum **Read** permission on **Repositories**. When a user initiates the Batch Changes OAuth flow, Sourcegraph automatically requests the elevated scopes needed:
398
+
399
+
-`REPO_READ` — read repository contents and metadata
400
+
-`REPO_WRITE` — push branches and create/update pull requests
401
+
402
+
#### Adding a Bitbucket Server OAuth credential
403
+
404
+
- Navigate to **User settings > Batch Changes**
405
+
- Click **Add credentials** for your Bitbucket Server code host
406
+
- Select **Bitbucket Server OAuth** as the **Authentication strategy**
407
+
- Click the **Authorize** button
408
+
- You will be redirected to your Bitbucket Server instance to grant access
409
+
- After authorizing, you will be redirected back to Sourcegraph with the credential automatically provisioned
410
+
411
+
#### Migrating from PATs to Bitbucket Server OAuth
412
+
413
+
You can migrate from personal access tokens to OAuth by deleting the existing PAT credential and creating a new one using the Bitbucket Server OAuth option. Existing batch changes will continue to work with the new credential.
414
+
415
+
### Bitbucket Cloud OAuth
416
+
417
+
#### Prerequisites
418
+
419
+
A Sourcegraph site administrator must configure a [Bitbucket Cloud authentication provider](/admin/auth#bitbucket-cloud). If your instance already uses Bitbucket Cloud for sign-in, this step is already complete.
420
+
421
+
The OAuth consumer in Bitbucket Cloud should have the following permissions enabled:
422
+
423
+
-**Account**: Read
424
+
-**Email**: Read
425
+
-**Repositories**: Read
426
+
-**Pull requests**: Read and Write
427
+
428
+
<Callouttype="warning">
429
+
If the OAuth consumer is missing required permissions, users will see an `invalid_scope` error
430
+
during the OAuth flow. Ensure all the above permissions are selected in your Bitbucket Cloud
431
+
workspace under **Settings > OAuth consumers**.
432
+
</Callout>
433
+
434
+
When a user initiates the Batch Changes OAuth flow, Sourcegraph requests the following scopes:
435
+
436
+
-`account` — read the authenticated user's account information
437
+
-`email` — read the authenticated user's email addresses
438
+
-`repository` — read and access repository contents
439
+
-`pullrequest:write` — create and update pull requests
440
+
441
+
#### Adding a Bitbucket Cloud OAuth credential
442
+
443
+
- Navigate to **User settings > Batch Changes**
444
+
- Click **Add credentials** for your Bitbucket Cloud code host
445
+
- Select **Bitbucket Cloud OAuth** as the **Authentication strategy**
446
+
- Click the **Authorize** button
447
+
- You will be redirected to Bitbucket Cloud to grant access
448
+
- After authorizing, you will be redirected back to Sourcegraph with the credential automatically provisioned
449
+
450
+
#### Migrating from app passwords to Bitbucket Cloud OAuth
451
+
452
+
You can migrate from app passwords to OAuth by deleting the existing credential and creating a new one using the Bitbucket Cloud OAuth option. Existing batch changes will continue to work with the new credential.
453
+
454
+
### Token refresh
455
+
456
+
OAuth tokens have limited lifetimes. Sourcegraph automatically refreshes tokens when they expire using the refresh token obtained during authorization. Token refresh is handled transparently — users do not need to re-authorize unless the refresh token itself is revoked or the OAuth consumer is deleted.
457
+
458
+
<Callouttype="warning">
459
+
The Bitbucket authentication provider must remain configured in the Sourcegraph site configuration
460
+
for token refresh to work. If the auth provider is removed, tokens will not be refreshed and will
461
+
eventually expire.
462
+
</Callout>
463
+
464
+
### Removing a Bitbucket OAuth credential
465
+
466
+
When a Bitbucket OAuth credential is removed, the linked external account used for Batch Changes is also cleaned up. This does not affect the user's ability to sign in to Sourcegraph via Bitbucket — sign-in and Batch Changes use separate external accounts.
0 commit comments