Integrate OAuth with Git experience
Configure your credentials for Git experience.
You can store configurations for your resources, such as pipelines and input sets, in Git using Harness Git Experience. Harness fetches user credentials from the Harness account and uses the corresponding user name as the author of the commit.
You can push configuration changes using your own credentials by integrating OAuth with Git. When you integrate OAuth with Git Experience, the credentials are stored in your Harness account user profile. These credentials are used for any subsequent commits.
This topic explains how to configure OAuth for Git Experience in Harness.
Configure OAuth for Git provider
Harness supports OAuth integration for the following Git providers:
GitHub
GitLab
Bitbucket SaaS
Self-hosted Bitbucket
This topic explains how to configure OAuth for GitHub.
To configure your credentials for Git:
Go to your user profile in Harness.
In Connect to a Git Provider, select GitHub.

Click Connect. The OAuth settings for the selected Git provider appear.

Click Authorize. Harness fetches the corresponding OAuth token associated with the Git provider and displays it under Access token for Git providers.

Configure OAuth for GitHub Enterprise
Harness supports OAuth integration for GitHub Enterprise. As a prerequisite, you need to create an OAuth App in your GitHub Enterprise instance.
Go to Creating an OAuth App to create an OAuth App.
As you begin setting up the OAuth App:
You must provide the Authorization callback URL. Initially, you can provide any valid URL to proceed. Later, this URL will be updated to the URL provided during New Provider set-up.
Keep the Client ID and Client Secret handy. You will need them to create the provider in Harness.
To configure your credentials for GitHub Enterprise:
Navigate to Account Settings in Harness.
Select Providers, then click New Provider.

Select GitHub as a provider.
Enter the Name and Domain URL of the provider. The Domain URL is the URL of your GitHub Enterprise instance.
Specify the Secret Manager. This is where the token related to GitHub Enterprise will be stored.
Specify the Delegate Selector, then click Continue.

Copy the Redirect URL provided on the Harness Credentials page and use it to update the Authorization callback URL in your GitHub Enterprise OAuth App.

Copy the Client ID and generated Client Secret from your GitHub Enterprise OAuth App and use them to complete the provider's setup.
After you configure the GitHub Enterprise provider, navigate to your user profile. Select Profile Overview. Under Connect to a Provider, click Select a Provider. Select Custom Provider, select the provider you created, then click Connect.

On the GitHub authorization page, click Authorize. Harness creates the access token.
Configure OAuth for Self-hosted Bitbucket provider
To configure your credentials for a self-hosted Bitbucket provider:
Go to your user profile in Harness.
Under Account providers, click New Provider.

Select Bitbucket as a provider.
Enter the Name and Domain URL of the provider.
Specify the Secret Manager. This is where you have the access token related to the BitBucket stored.
Specify the Delegate Selector, then click Continue.

Copy the Redirect URL provided on the Harness Credentials page.
Navigate to the settings for your self-hosted Bitbucket instance. Select Application Links, then click Create Link.
Enter the Name. Under Redirect URL, enter the URL from the Bitbucket Configuration step, then save it.
Return to Application Links. Open the settings for the application, then click View Credentials. Copy the Client ID and Client Secret. Use them to configure the provider on the Harness Credentials page, then save it.
After you configure the Bitbucket provider, navigate to your user profile. Select Profile Overview. Under Connect to a Provider, click Select a Provider. Select On-Prem, select the provider you created, then click Connect.

On the Bitbucket page, click Allow. Harness creates the access token.
Configure OAuth for Self-hosted Gitlab provider
To configure your credentials for a self-hosted GitLab provider:
Go to your user profile in Harness.
Under Account providers, click New Provider.

Select GitLab as a provider.
Enter the Name and Domain URL of the provider.
Specify the Secret Manager. This is where you have the access token related to the Gitlab stored.
Specify the Delegate Selector, then click Continue.

Go to User Settings, then select Applications. Enter the Name and Redirect URI from the GitLab Configuration step. Add the Scopes, then click Save Application.

Once you save the application, copy the Application ID and Secret and use these to configure the provider on the Harness Credentials page.
After you configure the GitLab provider, navigate to your user profile. Select Profile Overview. Under Connect to a Provider, click Select a Provider. Select On-Prem, select the provider you created, then click Connect.

On the GitLab page, click Authorize. Harness creates the access token.
Commit changes to Git with the configured OAuth token
To commit changes to Git using the configured OAuth token:
Go to an existing remote pipeline or create a new one.
Edit the pipeline and select Save. The Save Pipelines to Git settings appear. Harness displays the user name being used for this commit.

Select Save.
Go to your branch in the Git repository. It now displays the author details beside the commit.
Generate an OAuth access token with vanity URLs
Harness supports OAuth access tokens with vanity URLs for GitHub and GitLab.
GitHub
For GitHub, follow Configure OAuth for Git provider. Harness updates the configuration automatically.
GitLab
For GitLab, customers need to ensure that their Vanity URL is added to the OAuth application's redirect URI list. The OAuth application is set up by Harness, so customers will need to contact Harness Support to complete this process. They must provide their subdomain to have the Vanity URL whitelisted.
Example: If your subdomain is yourcompany.harness.io, the redirect URI would be:
https://yourcompany.harness.io/gateway/api/secret/oauth2/gitlab
Supported Vanity URL Format
Harness supports vanity URLs in the format https://<YOUR_SUBDOMAIN>.harness.io. The following combinations are invalid:
https://<YOUR_SUBDOMAIN_1>.<YOUR_SUBDOMAIN_2>.harness.iohttps://app.harness.io/<YOUR_SUBDOMAIN>
Enforce OAuth for commits
You can enforce OAuth for commits pushed from Harness to your Git provider.
To enable this setting:
Navigate to Account Settings → General → Default Setting → Git Experience → Enable OAuth for Commits.

If this setting is enabled but OAuth is not configured for your account, commits from Harness to Git fail.

To resolve this, configure OAuth for your Git provider before making changes.
Last updated
Was this helpful?
