> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudthinker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Provider Authentication

> Authenticate GitHub, GitLab, Bitbucket, Azure DevOps or AWS CodeCommit for Review, with the exact token scopes and webhooks each one needs.

This page covers the **Connect** and **Events** steps of the Review setup wizard: which credentials each Git provider takes, the minimum scopes, and the webhook that tells CloudThinker a pull request (PR) or merge request (MR) changed. Start the wizard from [Review setup](https://docs.cloudthinker.io/guide/code-review/setup.md), then come here for your provider.

## Prerequisites

* Workspace **Admin** in CloudThinker, with the **Review Setup** dialog open at the **Connect** step.
* On the provider side, permission to install apps, create access tokens, or create IAM roles for the repositories you want reviewed.
* Azure DevOps: permission to create service hooks in the project (Project Administrator by default).

## Pick an auth method

| Provider | Methods | Webhook |
| - | - | - |
| GitHub | GitHub App | Automatic |
| GitLab | OAuth, or Project / Group Access Token | Manual |
| Bitbucket Cloud | OAuth, or Workspace / Project / Repository Access Token | Automatic |
| Azure DevOps | Personal access token (PAT) | Manual (service hooks) |
| AWS CodeCommit | IAM role (recommended) or access keys | Script in AWS CloudShell |

Self-hosted GitLab is the only self-hosted provider you can connect in the wizard. GitHub connects to github.com and Bitbucket to bitbucket.org, so GitHub Enterprise Server and Bitbucket Data Center aren't options there.

> [!TIP]
>
> Prefer a project, group, workspace or repository token over a personal one where your provider offers it. Comments then come from a bot user, access stays scoped to those repositories, and you can revoke it without touching anyone's account.

## GitHub

**1. Install the GitHub App**

Click **Install GitHub App**. GitHub asks you to pick an organization or account, then **All repositories** or **Only select repositories**. Review can only list the repositories you grant here. GitHub shows the app's full permission list on that screen before you approve. It includes **Pull requests: Read and write** for comments and **Contents: Read and write**, which **Apply fix**, autofix and conflict resolution need to push commits.

**2. Return to the wizard**

After you approve, GitHub sends you back and the wizard continues on its own. Webhooks come with the app, so there's no **Events** step.

**Success state:** the dialog shows **Connected** and moves to **Repositories**.

To grant a repository later, open your organization or account settings on GitHub, go to **GitHub Apps**, click **Configure** next to the CloudThinker app, and add it under **Repository access**. Then add it in Review with **Add repository**.

> [!NOTE]
>
> Installing an app on a GitHub organization needs an organization owner. If you aren't one, ask an owner to approve the install.

## GitLab

> [tab] OAuth
>
> OAuth connects to GitLab.com only. For self-hosted GitLab, use an access token. With OAuth, comments appear as the person who connected.
>
> 1. Open the **OAuth** tab and click **Connect to GitLab**.
> 2. Approve access in GitLab. CloudThinker asks for these scopes: `api`, `read_api`, `read_repository`, `write_repository`, `openid`, `email` and `profile`.
> 3. Back in the wizard, [add the webhook](#configure-webhooks).

> [tab] Access token
>
> Use this for self-hosted GitLab, or to scope access to one project or group.
>
> 1. In GitLab, open the project or group, go to **Settings → Access Tokens**, and click **Add new token**.
> 2. Set the role and select the `api` scope. Use **Maintainer** if you'll use **Apply fix** or autofix on protected branches, otherwise **Developer**. Set an expiration date. Narrower scopes such as `read_api` or `write_repository` aren't enough: posting findings as merge request comments, resolving their threads and reading pipelines all go through the GitLab API, which needs `api`.
> 3. Copy the token.
> 4. In the wizard, open the **Access Token** tab and fill in the fields below.
> 5. Click **Validate Token**, wait for **Token works**, then click **Connect**.
> 6. [Add the webhook](#configure-webhooks).
>
> | Field | Value |
> | - | - |
> | **GitLab URL** | `https://gitlab.com`, or your instance URL such as `https://gitlab.example.com` |
> | **Token Type** | **Project Access Token** (one project) or **Group Access Token** (every project in the group) |
> | **Access Token** | The token, starting `glpat-` |
>
> > [!NOTE]
> >
> > A Guest or Reporter token can't comment on merge requests. A Developer token can't push to protected branches, so **Apply fix** and autofix fail there unless you allow Developers to push to them. On GitLab.com, Group Access Tokens need GitLab Premium or Ultimate.
>
> For self-hosted GitLab, CloudThinker must reach your **GitLab URL** over HTTPS, and your instance must reach the webhook URL from the **Events** step.

## Bitbucket

> [tab] OAuth
>
> 1. Open the **OAuth** tab and enter your Bitbucket workspace name (the `<workspace>` in `bitbucket.org/<workspace>/repo`).
> 2. Click **Connect to Bitbucket** and approve access.
>
> With OAuth, comments appear as the person who connected. Webhooks register automatically.

> [tab] Access token
>
> Pick the token type that matches the repositories you want reviewed:
>
> | Token Type | Covers | Bitbucket plan |
> | - | - | - |
> | **Workspace Access Token** | Every repository in a workspace | Premium |
> | **Project Access Token** | Every repository in a project | Premium |
> | **Repository Access Token** | One repository | Any |
>
> 1. Create the token in Bitbucket:
>    * Workspace: **Workspace → Settings → Access tokens → Create workspace access token**
>    * Project: **Project → Project settings → Access tokens → Create project access token**
>    * Repository: **Repository → Repository settings → Access tokens → Create Repository Access Token**
>
> 2. Grant these permissions and set an expiration date:
>
>    | Permission | Access | Needed for |
>    | - | - | - |
>    | Account | Read | Identifying the connection |
>    | Repositories | Read and write | Cloning, and pushing autofix and conflict resolution commits |
>    | Pull requests | Read and write | Reading PRs and posting findings |
>    | Webhooks | Read and write | Registering the webhook automatically |
>    | Pipelines | Read and write | [Pipeline analysis](https://docs.cloudthinker.io/guide/code-review/pipelines.md) |
>
>    The wizard asks for Pipelines **Read and write**, but CloudThinker only reads pipeline runs, steps and logs. If your policy requires least privilege, **Read** covers pipeline analysis.
>
> 3. In the wizard, open the **Access Token** tab and fill in the fields below.
>
> 4. Click **Validate Token**, wait for **Token works**, then click **Connect**.
>
> | Field | Value |
> | - | - |
> | **Token Type** | **Workspace Access Token**, **Project Access Token** or **Repository Access Token** |
> | **Bitbucket Workspace** | The `<workspace>` in `bitbucket.org/<workspace>/repo` |
> | **Repository slug** | Repository tokens only: the repository's slug |
> | **Access Token** | The token you copied |
>
> Webhooks register automatically.

## Azure DevOps

**1. Create a personal access token**

In Azure DevOps, go to **User settings → Personal access tokens** and click **New Token**. Pick the organization, set an expiration date, and enable these scopes:

| Scope | Access |
| - | - |
| Build | Read |
| Code | Read & Write |
| Pull Request Threads | Read & Write |

Copy the token. Azure DevOps posts comments as the person who owns the PAT, so create it from a dedicated service account. Then reviews keep working when someone leaves. Give that account the **Basic** access level (Stakeholder can't use Repos) and **Contributor** on the project, so it can read code and comment on pull requests.

**2. Connect in the wizard**

Fill in **Organization URL** (for example `https://dev.azure.com/myorg`), **Project** and **Personal Access Token**. Click **Validate PAT**, wait for **Token works**, then click **Connect**.

The connection covers the repositories in that one project. To review repositories in another project, set up Review in a separate workspace for it.

**Success state:** the dialog shows **Connected** and moves to **Events**.

**3. Add the service hooks**

Follow [Configure webhooks](#configure-webhooks).

## AWS CodeCommit

Both methods use a script the wizard generates for you. Run it in AWS CloudShell, or in any bash shell with the AWS CLI and credentials for the account (the access keys script also needs `jq`). A connection covers one AWS account and one region: the region you pick in the wizard.

> [tab] IAM role (recommended)
>
> 1. Select **IAM Role (recommended)** and choose the **AWS Region**. The wizard creates an External ID for your workspace.
> 2. Copy the script and run it in AWS CloudShell. It creates a role named `CloudThinkerCodeCommitAccessRole` with a trust policy scoped to CloudThinker and your External ID. If that role already exists, for example from an earlier setup, the script reuses it: it refreshes the trust policy for the new External ID and prints the existing ARN.
> 3. Copy the role ARN from the script's output into **Role ARN**, then click **Connect**.

> [tab] Access keys
>
> 1. Select **Access Keys** and choose the **AWS Region**.
> 2. Copy the script and run it in AWS CloudShell. It creates an IAM user with the CodeCommit permissions Review needs and an access key.
> 3. Paste the **Access Key ID** and **Secret Access Key** from the script's output, then click **Connect**.
>
> Access keys don't expire on their own. Rotate them on your normal schedule and paste the new pair with **Update token** in **Review → Settings → Connection**, or use the IAM role instead.

> [accordion] What the script creates
>
> The script attaches one inline policy with these actions:
>
> | Purpose | IAM actions |
> | - | - |
> | Read repositories and code | `codecommit:ListRepositories`, `GetRepository`, `GetDifferences`, `GetBlob`, `GetFile`, `GetFolder`, `GitPull` |
> | Read pull requests | `codecommit:ListPullRequests`, `GetPullRequest`, `GetCommentsForPullRequest`, `GetCommentReactions` |
> | Post findings | `codecommit:PostCommentForPullRequest`, `PostCommentReply`, `UpdateComment` |
> | Webhook events | `events:PutRule`, `PutTargets`, `DescribeRule`, `DeleteRule`, `RemoveTargets`, `ListTargetsByRule`, limited to rules named `CloudThinker-CodeCommit-*` |
>
> It doesn't grant `codecommit:GitPush` or `codecommit:CreatePullRequest`. [Auto-resolve conflicts](https://docs.cloudthinker.io/guide/code-review/conflict-resolution.md) needs both, so add them if you turn it on:
>
> 1. In the IAM console, open **Roles → CloudThinkerCodeCommitAccessRole** (or **Users → CloudThinkerCodeCommitUser** for access keys).
> 2. On **Permissions**, edit the inline policy: `CodeCommitReviewAccess` on the role, `CodeCommitReviewAccessKeyPolicy` on the user.
> 3. Add `codecommit:GitPush` and `codecommit:CreatePullRequest` to the `CodeCommitReviewActions` statement and save.
>
> The IAM role's trust policy lets only CloudThinker's AWS account assume the role, and only with your workspace's External ID. The script you copy from the wizard contains the full trust policy, with that account ID, so your security team can read it before you run it. The **Access Keys** method creates an IAM user named `CloudThinkerCodeCommitUser` with the same policy instead.

If the wizard says **no repositories found yet**, the connection works but the credentials can't see any repositories. Check the IAM permissions and the region.

## Configure webhooks

GitHub and Bitbucket need nothing here. For the other three, the **Events** step shows a webhook **URL** and **Secret token** to copy.

> [tab] GitLab
>
> 1. In GitLab, open the group or project and go to **Settings → Webhooks → Add new webhook**. Group webhooks need GitLab Premium or Ultimate. On the Free tier, add the webhook to each project instead.
> 2. Paste the **URL** and **Secret token** from the wizard. Leave **Enable SSL verification** on.
> 3. Enable **Merge request events** and **Comments**. Add **Pipeline events** if you use [pipeline analysis](https://docs.cloudthinker.io/guide/code-review/pipelines.md), **Tag push events** if you use [releases](https://docs.cloudthinker.io/guide/code-review/releases.md), and **Push events** if you use [auto-resolve conflicts](https://docs.cloudthinker.io/guide/code-review/conflict-resolution.md). Without Push events, a push to a target branch never reaches CloudThinker, so conflicts it causes aren't checked.
> 4. Save the webhook, then click **Mark as Configured** in the wizard.
>
> To check delivery, click **Test → Merge request events** next to the webhook, then edit it and look under **Recent events**.

> [tab] Azure DevOps
>
> Azure DevOps needs one service hook per event. Repeat these steps for each event below.
>
> 1. Go to **Project Settings → Service hooks** and click **+ Create subscription**.
> 2. Select **Web Hooks** and click **Next**.
> 3. In **Trigger**, pick one event and click **Next**.
> 4. Leave the repository and branch filters at **\[Any]**. Paste the **URL**. Paste the **Secret token** into the **Basic authentication password** field and leave the username empty. Click **Finish**.
>
> | Event | Needed for |
> | - | - |
> | **Pull request created** | Reviews |
> | **Pull request updated** | Reviews |
> | **Pull request commented on** | Mention commands. Set **Resource version** to **2.0**: CloudThinker ignores 1.0 comment events |
> | **Build completed** | Pipeline analysis |
> | **Code pushed** | Only for **Analyze new release tags** |
>
> Then click **Mark as Configured** in the wizard.

> [tab] AWS CodeCommit
>
> 1. Copy the script from the **Events** step. It already contains your webhook URL and secret token.
> 2. Run it in AWS CloudShell, or any bash shell with the AWS CLI, with credentials for the account that owns the repositories. It creates Amazon EventBridge rules that send events to CloudThinker, one set per CodeCommit repository that exists in the region when it runs.
> 3. When it prints "Webhook setup complete", click **Mark as Configured**.
>
> Because the rules are per repository, a repository you create later has none. Run the script again after you add repositories. It's safe to re-run.

**Success state:** you open a test PR or MR in a selected repository and a CloudThinker progress comment appears on it.

## Token expiry

GitLab and Bitbucket access tokens and Azure DevOps PATs expire on the date you set. Reviews stop when they do, and the Review page shows **Reconnect your Git provider**. Note the date when you create the token, and replace it before then: open **Review → Settings**, and in the **Connection** section open the actions menu (⋯) and click **Update token**. CodeCommit access keys don't expire on their own, but rotate them the same way. Review doesn't warn you before a token's expiry date, so put a reminder in your own calendar.

## Disconnect a provider

> [!WARNING]
>
> **Remove setup** deletes every reviewed MR/PR on **Review → Reviews** and every pipeline record in the workspace. Setting Review up again doesn't bring them back.

**1. Remove the setup in CloudThinker**

Open **Review → Settings**. In the **Connection** section, open the actions menu (⋯) and click **Remove setup**, then confirm. Review stops on every repository and the provider connection is removed. On GitHub, CloudThinker also uninstalls its app, and on Bitbucket it deletes the webhooks it registered. You can set it up again later.

**2. Revoke access on the provider**

Confirm the GitHub App is gone from your organization's **GitHub Apps** settings, or revoke the OAuth grant, delete the access token or PAT, or delete the IAM role or user the script created.

## Troubleshooting

> [accordion] Validate Token or Validate PAT fails
>
> **Cause:** usually a wrong URL or name, or a missing scope:
>
> * **GitLab:** the URL has a trailing path, or the token's role is below Developer.
> * **Bitbucket:** the workspace name or repository slug is wrong, a permission is missing, or you chose a workspace or project token on a plan without them.
> * **Azure DevOps:** the **Organization URL** isn't `https://dev.azure.com/<org>`, the **Project** name is wrong, or the PAT was made for another organization.
>
> **Fix:** correct the field, confirm the scopes in the tables above, and create a new token if needed. The wizard keeps what you typed, so you only replace what was wrong.

> [accordion] Connected, but no review on a new MR (GitLab, Azure DevOps, CodeCommit)
>
> **Cause:** the webhook is missing, has the wrong secret, or lacks a trigger.
>
> **Check:** open the webhook delivery history in your provider and look for failed requests.
>
> **Fix:** compare the URL, secret and triggers against [Configure webhooks](#configure-webhooks). For Azure DevOps, confirm all service hooks exist.

> [accordion] Mention commands get no reply on Azure DevOps
>
> **Cause:** the **Pull request commented on** hook uses resource version 1.0.
>
> **Fix:** edit that service hook and set **Resource version** to **2.0**.

> [accordion] Bitbucket asks you to confirm the workspace
>
> **Cause:** you connected with OAuth, and Bitbucket no longer lets CloudThinker find your workspace on its own.
>
> **Fix:** click **Set workspace**, enter your workspace name in **Bitbucket workspace**, and click **Save workspace**.

## Next steps

> [card] [Finish Review setup](https://docs.cloudthinker.io/guide/code-review/setup.md)
>
> Select repositories, choose a review mode and get your first review.

> [card] [Mention commands](https://docs.cloudthinker.io/guide/code-review/mention-commands.md)
>
> Talk to the reviewer from a PR or MR comment.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.