forked from usememos/memos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
808 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Authentication APIs | ||
|
||
## Sign In | ||
|
||
``` | ||
POST /api/v1/auth/signin | ||
``` | ||
|
||
**Request Body** | ||
|
||
```json | ||
{ | ||
"username": "john", | ||
"password": "password123" | ||
} | ||
``` | ||
|
||
**Response** | ||
|
||
```json | ||
{ | ||
"id": 123, | ||
"username": "john", | ||
"nickname": "John" | ||
// other user fields | ||
} | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: Sign in success | ||
- 400: Invalid request | ||
- 401: Incorrect credentials | ||
- 403: User banned | ||
- 500: Internal server error | ||
|
||
## SSO Sign In | ||
|
||
``` | ||
POST /api/v1/auth/signin/sso | ||
``` | ||
|
||
**Request Body** | ||
|
||
```json | ||
{ | ||
"identityProviderId": 123, | ||
"code": "abc123", | ||
"redirectUri": "https://example.com/callback" | ||
} | ||
``` | ||
|
||
**Response** | ||
|
||
Same as **Sign In** | ||
|
||
**Status Codes** | ||
|
||
- 200: Success | ||
- 400: Invalid request | ||
- 401: Authentication failed | ||
- 403: User banned | ||
- 404: Identity provider not found | ||
- 500: Internal server error | ||
|
||
## Sign Up | ||
|
||
``` | ||
POST /api/v1/auth/signup | ||
``` | ||
|
||
**Request Body** | ||
|
||
```json | ||
{ | ||
"username": "mary", | ||
"password": "password456" | ||
} | ||
``` | ||
|
||
**Response** | ||
|
||
Same as **Sign In** | ||
|
||
**Status Codes** | ||
|
||
- 200: Sign up success | ||
- 400: Invalid request | ||
- 401: Sign up disabled | ||
- 500: Internal server error | ||
|
||
## Sign Out | ||
|
||
``` | ||
POST /api/v1/auth/signout | ||
``` | ||
|
||
**Response** | ||
|
||
``` | ||
true | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: Success | ||
- 500: Internal server error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Guide to Access Memos API with OpenID | ||
|
||
Memos API supports using OpenID as the user identifier to access the API. | ||
|
||
## What is OpenID | ||
|
||
OpenID is a unique identifier assigned by Memos system to each user. | ||
|
||
When a user registers or logs in via third-party OAuth through Memos system, the OpenID will be generated automatically. | ||
|
||
## How to Get User's OpenID | ||
|
||
You can get a user's OpenID through: | ||
|
||
- User checks the personal profile page in Memos system | ||
- Calling Memos API to get user details | ||
- Retrieving from login API response after successful login | ||
|
||
Example: | ||
|
||
``` | ||
// GET /api/v1/user/me | ||
{ | ||
"id": 123, | ||
"username": "john", | ||
"openId": "8613E04B4FA6603883F05A5E0A5E2517", | ||
... | ||
} | ||
``` | ||
|
||
## How to Use OpenID to Access API | ||
|
||
You can access the API on behalf of the user by appending `?openId=xxx` parameter to the API URL. | ||
|
||
For example: | ||
|
||
``` | ||
curl 'https://demo.usememos.com/api/v1/memo?openId=8613E04B4FA6603883F05A5E0A5E2517' -H 'Content-Type: application/json' --data-raw '{"content":"Hello world!"}' | ||
``` | ||
|
||
The above request will create a Memo under the user with OpenID `8613E04B4FA6603883F05A5E0A5E2517`. | ||
|
||
OpenID can be used in any API that requires user identity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Memo Relation APIs | ||
|
||
## Create Memo Relation | ||
|
||
``` | ||
POST /api/v1/memo/:memoId/relation | ||
``` | ||
|
||
**Request Body** | ||
|
||
```json | ||
{ | ||
"relatedMemoId": 456, | ||
"type": "REFERENCE" | ||
} | ||
``` | ||
|
||
**Response** | ||
|
||
```json | ||
{ | ||
"memoId": 123, | ||
"relatedMemoId": 456, | ||
"type": "REFERENCE" | ||
} | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: OK | ||
- 400: Invalid request | ||
- 500: Internal server error | ||
|
||
## Get Memo Relations | ||
|
||
``` | ||
GET /api/v1/memo/:memoId/relation | ||
``` | ||
|
||
**Response** | ||
|
||
```json | ||
[ | ||
{ | ||
"memoId": 123, | ||
"relatedMemoId": 456, | ||
"type": "REFERENCE" | ||
} | ||
] | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: OK | ||
- 500: Internal server error | ||
|
||
## Delete Memo Relation | ||
|
||
``` | ||
DELETE /api/v1/memo/:memoId/relation/:relatedMemoId/type/:relationType | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: Deleted | ||
- 400: Invalid request | ||
- 500: Internal server error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Memo Resource APIs | ||
|
||
## Bind Resource to Memo | ||
|
||
``` | ||
POST /api/v1/memo/:memoId/resource | ||
``` | ||
|
||
**Request Body** | ||
|
||
```json | ||
{ | ||
"resourceId": 123 | ||
} | ||
``` | ||
|
||
**Response** | ||
|
||
``` | ||
true | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: OK | ||
- 400: Invalid request | ||
- 401: Unauthorized | ||
- 404: Memo/Resource not found | ||
- 500: Internal server error | ||
|
||
## Get Memo Resources | ||
|
||
``` | ||
GET /api/v1/memo/:memoId/resource | ||
``` | ||
|
||
**Response** | ||
|
||
```json | ||
[ | ||
{ | ||
"id": 123, | ||
"filename": "example.png" | ||
// other resource fields | ||
} | ||
] | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: OK | ||
- 500: Internal server error | ||
|
||
## Unbind Resource from Memo | ||
|
||
``` | ||
DELETE /api/v1/memo/:memoId/resource/:resourceId | ||
``` | ||
|
||
**Status Codes** | ||
|
||
- 200: OK | ||
- 401: Unauthorized | ||
- 404: Memo/Resource not found | ||
- 500: Internal server error |
Oops, something went wrong.