Skip to content

Commit

Permalink
Update API doc for protected endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
sneha-afk authored Feb 9, 2024
1 parent 1e887f8 commit 80d7aee
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions API_Interaction.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Backend API Interactions

## Getting All User Tasks (GET)
## Protected endpoints

All the endpoints below are protected by authenticating the user's session cookies before allowing requests or redirects to happen.

In your requests, make sure to include credentials with the `credentials: 'include'` parameter so these are passed on appropriately:
```js
const response = await fetch(backend/protected, {
method: 'GET',
credentials: 'include',
});
```

### Getting All User Tasks (GET)

- **Endpoint**: `/api/v1/tasks`
- **Description**: Get all tasks for a specific user.
Expand All @@ -27,9 +39,11 @@
}
```

## Get Task by ID (GET)
### Get Task by ID (GET)

- **Endpoint**: `/api/v1/task/:id`
- **NOTE**: do not include the `:` in your own requests
- Ex.: `/api/v1/task/1`
- **Description**: Get a task by ID.
- **Request Method**: GET
- **Parameters**:
Expand All @@ -56,7 +70,7 @@
}
```

## Create Task (POST)
### Create Task (POST)

- **Endpoint**: `/api/v1/task`
- **Description**: Create a new task.
Expand Down Expand Up @@ -89,9 +103,11 @@
}
```

## Edit Task (PUT)
### Edit Task (PUT)

- **Endpoint**: `/api/v1/task/:id`
- **NOTE**: do not include the `:` in your own requests
- Ex.: `/api/v1/task/1`
- **Description**: Edit an existing task.
- **Request Method**: PUT
- **URL Parameters**:
Expand All @@ -118,7 +134,7 @@
- **Response**:
- **Status Code**: 200 OK

## Delete Task (DELETE)
### Delete Task (DELETE)

- **Endpoint**: `/api/v1/task/:id`
- **Description**: Delete a task by ID.
Expand All @@ -130,10 +146,11 @@

## User login
- **Endpoint**: `/login`
- **Description**: Go **directly** to {backend_url}/login to access this endpoint as it loads request headers to send to Auth0. Do not send a GET to /login or these headers get lost.
- **Description**: Go **directly** to {backend_url}/login to access this endpoint as it loads request headers to send to Auth0. **Do not send a GET** to /login or these headers get lost.
- **Response**:
- **Status Code**: 307
- Redirects to Auth0 and comes back with another redirect to `backend/callback` (to confirm logged in token)
- You do not need to route to `/callback`

## User logout
- **Endpoint**: `/logout`
Expand Down

0 comments on commit 80d7aee

Please sign in to comment.