Connecting GitLab to Airbyte Using OAuth 2.0
Steps Followed
1. Create an OAuth Application in GitLab
- Go to GitLab Source Control Panel.
- Navigate to Applications and click Create New Application.
- Fill in the details:
- Name: Airbyte GitLab Integration (or any name you prefer)
- Redirect URI:
http://localhost:8000/workspaces/<workspace-id>/connections - Scopes:
api(required for full access)
- After creating, note the:
client_idclient_secret
2. Generate Authorization Code
Paste this URL in your browser (replace placeholders accordingly):
https://gitlab.example.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=api
Example:
https://gitlab.example.com/oauth/authorize?client_id=c4505a79...eca13&redirect_uri=http://localhost:8000/workspaces/123/connections&response_type=code&scope=api
- Approve the application when prompted.
- You will be redirected, and the URL will contain
?code=<authorization_code>. - Copy the authorization code from the URL.
3. Exchange Code for Access & Refresh Token
Use this curl command in your terminal (replace placeholders):
curl --location 'https://gitlab.example.com/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=YOUR_CLIENT_ID' \
--data-urlencode 'client_secret=YOUR_CLIENT_SECRET' \
--data-urlencode 'code=YOUR_AUTHORIZATION_CODE' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'redirect_uri=YOUR_REDIRECT_URI'
You will receive a JSON response containing refresh_token, access_token, and token_expiry. Save these values.
4. Configure Airbyte Source
In Airbyte:
- Choose GitLab as the source.
- Set the Authorization Method to OAuth2.0.
- Fill in the following fields:
- access_token: the token from Step 3
- refresh_token: the refresh token from Step 3
- client_id: your GitLab OAuth app client ID
- client_secret: your GitLab OAuth app client secret
- token_expiry_date: the expiry timestamp from the API response
- API URL:
https://gitlab.example.com/api/v4 - Optional: group/project IDs to scope the connection
- Click Test the source to verify the connection.