-
Notifications
You must be signed in to change notification settings - Fork 3
Author API Documentation
API used to manage all aspects of user/author identity on Konnection. It offers endpoints so users can sign up, log in, update and retrieve their profiles.
Go to the same directory as manage.py
, enter the following line into and follow the system instruction
python manage.py createsuperuser
Get: /api/author/{id}/
Getting an author's profile
- Provide Token in the header for authentication purpose
- Logged in user must be approved by admin
Request Header | Required / optional | Description | Type |
---|---|---|---|
Authorization | required | Authentication Token | String |
Sample header
--header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"
The following is a sample response from the endpoint:
{
"username": "test",
"type": "author",
"id": "6oidshfihfdiubw-12124",
"host": "https://konnection-client.herokuapp.com",
"displayName": "test",
"url": "https://konnection-client.herokuapp.com/author/6oidshfihfdiubw-12124",
"github": "https://blob.github.com"
}
Response Status Code
-
200 OK
Returns author object -
401 Unauthorized
User not logged in -
400 Bad Request
Not a valid user ID
GET: /api/author/me/
Getting the profile of the logged in author.
- Provide Token in the header for authentication purposes.
- Logged in user must be approved by admin
Request Header | Required / optional | Description | Type |
---|---|---|---|
Authorization | required | Authentication Token | String |
Sample header
--header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"
The following is a sample response from the endpoint:
{
"username": "test",
"type": "author",
"id": "6oidshfihfdiubw-12124",
"host": "https://konnection-client.herokuapp.com",
"displayName": "test",
"url": "https://konnection-client.herokuapp.com/author/6oidshfihfdiubw-12124",
"github": "https://blob.github.com"
}
Response Status Code
-
200 OK
Returns author object -
401 Unauthorized
User not logged in
POST: /api/author/create/
Create an author account.
- Logged in user must be approved by admin
Request body | Required / optional | Description | Type |
---|---|---|---|
username | required | The user's desired username | String |
password | required | The user's desired password | String |
The following is a sample response from the endpoint:
{}
Response Status Code
-
201 Created
User is successfully created
POST: /api/author/auth/
To authenticate/login an author. The endpoint will return a token belongs to that author after the authentication.
- Provide Token in the header for authentication purposes.
- Logged in user must be approved by admin
Request Header | Required / optional | Description | Type |
---|---|---|---|
Authorization | required | Authentication Token | String |
Sample header
--header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"
The following is a sample response from the endpoint:
{
"token":"dsfjosjfjsdlfnksanfk-noawenfon",
}
Response Status Code
-
200 OK
Returns a token object
PUT: /api/author/{id}/
Author to update their profile
- Provide Token in the header for authentication purposes.
- Logged in user must be approved by admin
Request Header | Required / optional | Description | Type |
---|---|---|---|
Authorization | required | Authentication Token | String |
Sample header
--header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"
Request Body | Required / optional | Description | Type |
---|---|---|---|
displayName | optional | The user's desired display name | String |
github | optional | The user's desired GitHub URL | String |
The following is a sample response from the endpoint:
{
"username": "testing12",
"type": "author",
"id": "xxxxxxxxxxx",
"host": "",
"displayName": "",
"url": "",
"github": ""
}
Response Status Code
-
200 OK
Returns author object -
401 Unauthorized
Does not have permission to edit this profile
GET: /api/authors/
To get a list of all local authors, excluding superuser and not admin approved author.
- Provide Token in the header for authentication purposes.
- Logged in user must be approved by admin
Request Header | Required / optional | Description | Type |
---|---|---|---|
Authorization | required | Authentication Token | String |
Sample header
--header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"
The following is a sample response from the endpoint:
[
{
"username": "abc001",
"type": "author",
"id": "xxx",
"host": "xxx",
"displayName": "",
"url": "",
"github": ""
},
...
]
Response Status Code
-
200 OK
Returns a list of local authors
GET: /api/all-authors/
To get a list of all local and remote authors, excluding superuser and not admin approved author.
- Provide Token in the header for authentication purposes.
- Logged in user must be approved by admin
Request Header | Required / optional | Description | Type |
---|---|---|---|
Authorization | required | Authentication Token | String |
Sample header
--header "Authorization: Token 7ccf51cf9b2b518d789bdeaf5de1db0e530e1ab5"
The following is a sample response from the endpoint:
{
"errors": {
"https://wrong-credentials.com/api/authors/": {
"detail": "Invalid username/password."
}
},
"authors": [
{
"username": "abc001",
"type": "author",
"id": "xxx",
"host": "xxx",
"displayName": "",
"URL": "",
"github": ""
},
{
"type": "author",
"id": "https://team6-project-socialdistrib.herokuapp.com/author/84f4ec29d64d488794550052024024b1",
"host": "https://team6-project-socialdistrib.herokuapp.com/",
"displayName": "remote",
"url": "https://team6-project-socialdistrib.herokuapp.com/author/84f4ec29d64d488794550052024024b1",
"github": "www.github.com/remote"
}
]
}
Response Status Code
-
200 OK
Returns a list of local and remote authors