Skip to content

Commit

Permalink
api folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankcorn committed Nov 14, 2023
1 parent 0c4bae7 commit 2e5fcba
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
142 changes: 142 additions & 0 deletions api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
label: API Integration
order: -10
icon: globe
---

# API Integration

Integrate with Baselime to provide an exceptional observability experience for your customers out of the box.

### Step 1: Creating an Integration

To create an OAuth Integration get in touch with the Baselime Team by emailing [[email protected]](mailto:[email protected]). Or by signing in to the [Baselime Console](https://console.baselime.io) and going to the `/integrations` page.

The following information is required

| Field | Description |
| ----------- | ----------------------------------------------------------------- |
| name | The name of the integration |
| description | A detailed description of the integration |
| logo | A URL pointing to your logo. |
| redirect | The URL to redirect users after completing the integration setup. |


Once you have created the Integration you will receive a Client ID and Client Secret

Test the integration at `https://console.baselime.io/integrations/<your-client-id>`.

![A Baselime Integration](../assets/images/illustrations/integrations.png)

Once the user has Authorized your application they will be redirected to your redirect with the temporary authorization code in the query string parameters.

`https://www.example.com/get?code=4fa87ba8cc7f30e91ad2ab1ad21c1b3e`

!!!
The code is valid for 3 minutes.
!!!

### Step 2: Exchanging the code for an Access Token and Refresh Token

Use the temporary authorisation code to retrieve a short-lived access token for first-time access. When it's retrieved, a long-lived refresh token is also returned. The refresh token is used to generate a new access token.

#### Exchanging the code for an access token and refresh token

### Endpoint

- **Method**: `POST`
- **URL**: `https://api.baselime.cc/oauth/token`

### Request

#### Headers

- **Content-Type**: `application/json`

#### Body

```json # :icon-code:
{
"grantType": "authorization_code",
"clientId": "<your-client-id>",
"clientSecret": "<your-client-secret>",
"redirect": "<your-redirect-url>",
"code": "<oauth-code>"
}
```
- **grantType** (string): Type of grant, e.g., "authorization_code".
- **clientId** (string): Client ID for authentication.
- **clientSecret** (string): Client secret for authentication.
- **redirect** (string): Redirect URL.
- **code** (string): Authorization code.

### Response

#### HTTP Status: `200 OK`

```json # :icon-code:
{
"accessToken": "0eg45oih65ihj4gjiojerjoi3g45j0g4",
"refreshToken": "435huo4wwwwwhu9j4398653g9woeirjgq3984ig5whrek5ejh9jg9wehgw",
"expiresIn": 86400,
"tokenType": "Bearer"
}
```
- **accessToken**: JWT access token.
- **tokenType**: Type of token, e.g., "Bearer".
- **expiresIn**: Token expiration time in seconds.
- **refreshToken**: Refresh token for obtaining a new access token.


### Step 3: Exchanging the Refresh Token for an Access Token

The access token grants access for 24 hours. If you will need access for longer than that you should use the refresh token to generate a new access token. The refresh token does not expire unless access is revoked.

#### Exchanging the code for an access token and refresh token

### Endpoint

- **Method**: `POST`
- **URL**: `https://api.baselime.cc/oauth/token`

### Request

#### Headers

- **Content-Type**: `application/json`

#### Body

```json # :icon-code:
{
"grantType": "refresh_token",
"clientId": "<your-client-id>",
"clientSecret": "<your-client-secret>",
"redirect": "<your-redirect-url>",
"refreshToken": "<refresh-token>"
}
```
- **grantType** (string): Type of grant, e.g., "refresh_token".
- **clientId** (string): Client ID for authentication.
- **clientSecret** (string): Client secret for authentication.
- **redirect** (string): Redirect URL.
- **refreshToken** (string): Refresh Token.

### Response

#### HTTP Status: `200 OK`

```json # :icon-code:
{
"accessToken": "0eg45oih65ihj4gjiojerjoi3g45j0g4",
"expiresIn": 86400,
"tokenType": "Bearer"
}
```
- **accessToken**: JWT access token.
- **tokenType**: Type of token, e.g., "Bearer".
- **expiresIn**: Token expiration time in seconds.


### Step 4: List users environments

Binary file added assets/images/illustrations/integrations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2e5fcba

Please sign in to comment.