Introduction to OAuth 2.0
Buddy API uses OAuth 2.0 for authentication. OAuth 2.0 is a protocol that lets external apps request authorization to private details in the user’s data without getting his password. Tokens can be limited to specific types of data, and can be revoked by users at any time. All developers need to register their application before getting started. A registered OAuth application is assigned a unique Client ID and Client Secret. The Client Secret should not be shared.
March 2022 update
In the old applications, the tokens never expire (just as they did before). If your app uses the old type of tokens, you will see this notice on the application screen:
Image loading...
Expired tokens can be regenerated using the refresh token. Tokens regenerated for the old type of apps also come with the refresh token, even though they do not expire.
Creating new OAuth app
To create a new app using our API go to your Buddy account settings to create Apps, or click on your avatar in the top right corner → select Apps from the menu.
In the Apps tab you will find the list of your apps, click + to add a new app.
Image loading...
A new window will show up asking you to fill the following fields:
| Name | Description |
|---|---|
application name Required | The application name displayed in Buddy. |
homepage URL Required | The full URL to your application homepage. |
authorization callback URLs Required | One or more URLs in your app where users will be sent after authorization. You can add multiple redirect URIs. |
| application description | The description displayed to all users of your application. |
| logo | The logo displayed on your application list. |
After saving the form, you will receive the application's authentication credentials:
Client ID- the public identifier of your app.Client Secret- a confidential key required for authentication.
Image loading...
Save this information in a secure place immediately, as the secret will no longer be available after closing the popup. If you lose the Client Secret, you can reset it in the application settings.
Image loading...
Web application flow
1. Redirecting user to address to gain access
GET https://api.buddy.works/oauth2/authorize
example:
https://api.buddy.works/oauth2/authorize?type=web_server&client_id=<CLIENT_ID>&redirect_uri=<REDIRECT_URI>&response_type=code&scope=<SCOPE>&state=<STATE>
GET Parameters
| Name | Type | Description |
|---|---|---|
type Required | String | Must be set to web_server. |
client_id Required | String | Client ID. Received when registering the app. |
| redirect_uri | String | The redirect_uri parameter is optional. If left out, Buddy will redirect users to the callback URL configured in the OAuth Application settings. If provided, the redirect URL’s host and port must exactly match the callback URL. The redirect URL’s path must reference a subdirectory of the callback URL. |
response_type Required | String | Must be set to code. |
scope Required | String | The list of scopes |
| state | String | An unguessable random string. It is used to protect against cross-site request forgery attacks. |
The user will receive a website with login form to your Buddy workspace. In the next step he can either allow access for your app with the required scopes.
Image loading...
2. Receiving authentication code
If the user accepts your application, he gets redirected to redirect_uri (see previous step) with two parameters:
https://<REDIRECT_URI>?code=<CODE>&state=<STATE>
| Name | Type | Description |
|---|---|---|
| code | String | To be exchanged for access token in the next step. |
| state | String | The state posted before. Must be the same as original. If it’s not the same, you should cancel the authentication process. |
3. Exchanging code for access token
In the next step, you need to send the code in the following request:
POST https://api.buddy.works/oauth2/token
Content-Type: application/x-www-form-urlencoded
POST Parameters
| Name | Type | Description |
|---|---|---|
code Required | String | The code that you received in the previous step. |
client_id Required | String | Client ID - received during app registration. |
client_secret Required | String | Client Secret - received during app registration. |
| redirect_uri | String | IMPORTANT: This param is required if the redirect_uri parameter is included in the authorization request (as described in this section). Their values must be identical. |
grant_type Required | String | Must be set to authorization_code. |
example:
curlcurl --request POST https://api.buddy.works/oauth2/token \ --header "Content-Type: application/x-www-form-urlencoded" \ --data "grant_type=authorization_code&code=<CODE>&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&redirect_uri=<REDIRECT_URI>"
You will receive the following response.
Basic authorization
Authorization is used mainly to test the app by a developer. Only the app developer may authenticate. To retrieve the access token, you need to execute this request:
POST https://api.buddy.works/oauth2/token
Attach this HTTP header:
'Authorization: Basic ' + base64(client_id + ':' + client_secret)
POST Parameters
| Name | Type | Description |
|---|---|---|
grant_type Required | String | Must be set to client_credentials. |
scope Required | String | The list of scopes; divided with space |
Authentication response
The method POST https://api.buddy.works/oauth2/token will produce a response like this:
json{ "access_token": "732e9e20-50ba-4047-8a7b-c9b17259a2a2", "expires_in": 28800, "refresh_token": "p8gUgmrXwe5CT2TMiMMkpIIRlIMlH70aB19dxwGJJkNWp4LthWUjJDmmUmBd7xLPzDq8R5PtCvx0SvAS", "refresh_token_expires_in": 158112000, "token_type": "Bearer" }
| Name | Type | Description |
|---|---|---|
| access_token | String | The token used to authenticate the requests in the API. |
| expires_in | int | The number of seconds in which the access token expires. |
| refresh_token | String | Required to refresh the access token once it expires. |
| refresh_token_expires_in | int | The number of seconds in which the refresh token expires. |
| token_type | String | The type of the token (at the moment only bearer is supported by Buddy). |
Refreshing tokens
The returned token is used to authenticate when invoking API methods. Keep in mind that tokens created in Buddy before March 29, 2022, never expire. Tokens generated after that date expire in 8 hours from the creation.
If the token expires, the request to the API will return the following response:
json401 Unauthorized { "errors": [ { "message": "Wrong authentication data" } ] }
In such case, you need to run this request to refresh it:
POST https://api.buddy.works/oauth2/token
Content-Type: application/x-www-form-urlencoded
POST Parameters
| Name | Type | Description |
|---|---|---|
| refresh_token | String | The refresh token that you received with the previous token. |
client_id Required | String | Client ID - received during app registration. |
client_secret Required | String | Client Secret - received during app registration. |
grant_type Required | String | Must be set to refresh_token. |
You will receive the following response.
- Refresh tokens are valid for 6 months.
- A token can be refreshed even if it has not yet expired.
- The refresh invalidates the current
access_tokenandrefresh_token
OAuth app management
After registering and deploying the OAuth application, you may need to manage its credentials or user access.
Authorized apps
The "Authorized OAuth apps" section shows which applications have gained access to your Buddy account.
Image loading...
Resetting the Client Secret
If your Client Secret has been exposed or you don't remember it, you can reset it in the application settings.
Note: The old secret will stop working immediately and cannot be restored.
Revoking all user tokens
To force all users of the application to reauthorize (e.g., after a security incident), you can revoke all user tokens.
Warning: This action is immediate and irreversible.
Supported scopes
| Name | Description |
|---|---|
| User scopes | |
| USER_READ | Access to base information of the authorized user. |
| USER_WRITE | Permission to update the profile of the authorized user (contains USER_READ rights). |
| User SSH key scopes | |
| USER_SSH_KEY_READ | Access to public SSH keys of the authorized user. |
| USER_SSH_KEY_WRITE | Permission to add SSH keys of the authorized user (contains USER_SSH_KEY_READ rights). |
| USER_SSH_KEY_MANAGE | Permission to delete SSH keys of the authorized user (contains USER_SSH_KEY_WRITE rights). |
| User email scopes | |
| USER_EMAIL_READ | Access to email list of the authorized user. |
| USER_EMAIL_WRITE | Permission to add email addresses of the authorized user (contains USER_EMAIL_READ rights). |
| USER_EMAIL_MANAGE | Permission to delete email addresses of the authorized user (contains USER_EMAIL_WRITE rights). |
| Personal access token scopes | |
| USER_PAT_READ | Access to personal access tokens info. |
| USER_PAT_WRITE | Permission to add personal access tokens (contains USER_PAT_READ rights). |
| USER_PAT_MANAGE | Permission to delete personal access tokens (contains USER_PAT_WRITE rights). |
| Workspace scopes | |
| WORKSPACE_PROVISIONING | Permission to create, update and delete workspaces. |
| WORKSPACE_READ | Access to basic workspace information. |
| WORKSPACE_MANAGE | Permission to manage workspace settings including SSO (contains WORKSPACE_READ rights). |
| Project scopes | |
| PROJECT_READ | Access to projects info including member and group assignments. |
| PROJECT_WRITE | Permission to add/edit projects and manage their member and group assignments (contains PROJECT_READ rights). |
| PROJECT_MANAGE | Permission to delete projects (contains PROJECT_WRITE rights). |
| Member scopes | |
| MEMBER_READ | Access to workspace members info. |
| MEMBER_WRITE | Permission to add/edit workspace members (contains MEMBER_READ rights). |
| MEMBER_MANAGE | Permission to remove workspace members (contains MEMBER_WRITE rights). |
| MEMBER_EMAIL_READ | Access to contact info of workspace members. |
| Group scopes | |
| GROUP_READ | Access to groups and group memberships info. |
| GROUP_WRITE | Permission to add/edit groups and manage their memberships (contains GROUP_READ rights). |
| GROUP_MANAGE | Permission to delete groups (contains GROUP_WRITE rights). |
| Permission scopes | |
| PERMISSION_READ | Access to permission sets info. |
| PERMISSION_WRITE | Permission to add/edit permission sets (contains PERMISSION_READ rights). |
| PERMISSION_MANAGE | Permission to delete permission sets (contains PERMISSION_WRITE rights). |
| Repository scopes | |
| REPOSITORY_READ | Access to commits and repository content. Repository checkout is allowed, too. |
| REPOSITORY_WRITE | Permission to write in the repository. File deletion is allowed, too (contains REPOSITORY_READ rights). |
| Pipeline scopes | |
| PIPELINE_READ | Access to pipelines and executions history. |
| PIPELINE_RUN | Permission to run and stop pipelines (contains PIPELINE_READ rights). |
| PIPELINE_WRITE | Permission to add/edit pipelines and their actions (contains PIPELINE_RUN rights). |
| PIPELINE_MANAGE | Permission to delete pipelines and manage filesystem files (contains PIPELINE_WRITE rights). |
| Target scopes | |
| TARGET_READ | Access to targets info. |
| TARGET_USE | Permission to run and cancel commands on targets (contains TARGET_READ rights). |
| TARGET_WRITE | Permission to add/edit targets (contains TARGET_USE rights). |
| TARGET_MANAGE | Permission to delete targets (contains TARGET_WRITE rights). |
| Domain scopes | |
| DOMAIN_READ | Access to the domains info. |
| DOMAIN_WRITE | Permission to add/edit/delete domain's records (contains DOMAIN_READ rights). |
| DOMAIN_MANAGE | Permission to create, register and delete domains (contains DOMAIN_WRITE rights). |
| Integration scopes | |
| INTEGRATION_READ | Access to the list of integrations available to the authorized user. |
| INTEGRATION_WRITE | Permission to add/edit integrations (contains INTEGRATION_READ rights). |
| INTEGRATION_MANAGE | Permission to delete integrations (contains INTEGRATION_WRITE rights). |
| Webhook scopes | |
| WEBHOOK_READ | Access to webhooks info. |
| WEBHOOK_WRITE | Permission to add/edit webhooks (contains WEBHOOK_READ rights). |
| WEBHOOK_MANAGE | Permission to delete webhooks (contains WEBHOOK_WRITE rights). |
| Variable scopes | |
| VARIABLE_READ | Access to environment variables' info. |
| VARIABLE_WRITE | Permission to add/edit environment variables (contains VARIABLE_READ rights). |
| VARIABLE_MANAGE | Permission to delete environment variables (contains VARIABLE_WRITE rights). |
| Environment scopes | |
| ENVIRONMENT_READ | Access to environments info. |
| ENVIRONMENT_WRITE | Permission to add/edit environments (contains ENVIRONMENT_READ rights). |
| ENVIRONMENT_MANAGE | Permission to delete environments (contains ENVIRONMENT_WRITE rights). |
| Distribution scopes | |
| DISTRIBUTION_READ | Access to distributions and routes info. |
| DISTRIBUTION_WRITE | Permission to add/edit distributions and routes (contains DISTRIBUTION_READ rights). |
| DISTRIBUTION_MANAGE | Permission to delete distributions and routes (contains DISTRIBUTION_WRITE rights). |
| Sandbox scopes | |
| SANDBOX_READ | Access to sandboxes info and snapshots. |
| SANDBOX_WRITE | Permission to add/edit, start/stop sandboxes and execute commands (contains SANDBOX_READ rights). |
| SANDBOX_MANAGE | Permission to delete sandboxes and snapshots (contains SANDBOX_WRITE rights). |
| Unit test scopes | |
| UNIT_TEST_READ | Access to unit tests info. |
| UNIT_TEST_WRITE | Permission to add unit test suites, manage sessions and report results (contains UNIT_TEST_READ rights). |
| UNIT_TEST_MANAGE | Permission to delete unit test suites and sessions (contains UNIT_TEST_WRITE rights). |
| Visual test scopes | |
| VISUAL_TEST_READ | Access to visual tests info. |
| VISUAL_TEST_WRITE | Permission to add visual test suites and report results (contains VISUAL_TEST_READ rights). |
| VISUAL_TEST_MANAGE | Permission to delete visual test suites (contains VISUAL_TEST_WRITE rights). |
| Crawl scopes | |
| CRAWL_READ | Access to crawl suites and sessions info. |
| CRAWL_WRITE | Permission to add/edit crawl suites and report results (contains CRAWL_READ rights). |
| CRAWL_MANAGE | Permission to delete crawl suites (contains CRAWL_WRITE rights). |
| Artifact scopes | |
| ARTIFACT_READ | Access to artifacts info. |
| ARTIFACT_WRITE | Permission to get and add artifacts. |
| ARTIFACT_MANAGE | Permission to add/edit and delete artifacts. |
| Tunnel scopes | |
| TUNNEL_READ | Access to tunnels info including the agent installation token. |
| TUNNEL_MANAGE | Permission to regenerate the tunnel token (contains TUNNEL_READ rights). |
Last modified on Sep 2, 2026