Google Source Repositories
To integrate with Google, we would create an OAuth App, and register the generated credentials with DeepSource (via Kotsadm) — so that it knows where to route API requests to.
-
First, we configure the consent screen. Google mandates that you share the same consent screen across all your apps (per project), so if you’ve already configured the consent screen for any other app, you can skip to the next step:
- Go to APIs and Services/OAuth consent screen.
- Select the correct project from the project switcher.
- If the consent screen isn’t already configured, you’d need to select the audience type: “Internal” if you want to restrict installation to members only, or else “External”.
- Give the app an appropriate name.
- Add your email as the support email and in developer contact information.
- Click “Save and continue”.
-
On the next page, click “Add or remove scopes”. On the menu which appears on the right, scroll down and add the following permissions:
- Click “Add to table”. The scopes should now have been added to the table and selected.
- Click “Update”. Once the menu closes, click “Save and continue”.
- Cross-check this information in summary shown.
-
Go to APIs and Services/Google Cloud Credentials:
- Click ”+ Create credentials”. Select “OAuth Client ID” from the dropdown.
- Select “Web application” as the application type.
- Give an appropriate name, e.g., “DeepSource”.
- Under the heading “Authorized Redirect URIs”, add https://deepsource.company.com/accounts/google/login/callback/bifrost/ (Replace deepsource.company.com with the URL at which deepsource is deployed).
- Click “Create”. It shall now display Client ID and Client Secret. Keep both of these values handy: we’ll need them later.
-
DeepSource uses the Cloud Resource Manager API (to list and view projects) and Cloud Source Repositories API (to read source code). If the APIs are not enabled, enable them by vising the following (make sure to select the correct project):
Configuring Google Source Repositories in the Admin Console
- Enable “Google Source Repositories” by clicking on the checkbox.
- Enter the Client ID and Secret you copied above.
- Enter a random string for “GSR Webhook Audience”. Make sure to note it somewhere safe as you’ll be asked to enter it again when registering webhooks later. You can use the following command:
Now your instance is ready, and you can go ahead and “Sign in with Google”. Once you select a project, you’ll also need to perform the following before proceeding:
Turn on webhooks
Running the following script will set it up for you:
Register the SSH Key
-
Copy the SSH key from the screen.
-
Go to https://source.cloud.google.com/user/ssh_keys?register=true. It might ask you for a password:
- Add a suitable name, e.g., “deepsource”
- Paste the public key and click “Register”.