Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
aditeyabaral committed Dec 24, 2024
1 parent 215f590 commit 1bfc6ba
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A simple API to authenticate PESU credentials using PESU Academy

The API is secure and protects user privacy by not storing any user credentials. It only validates credentials and
returns the user's profile information.
returns the user's profile information. No personal data is stored or logged.

### PESUAuth LIVE Deployment

Expand Down Expand Up @@ -58,16 +58,19 @@ your system.

# How to use pesu-auth

You can send a request to the `/authenticate` endpoint with the user's credentials and the API will return a JSON object,
You can send a request to the `/authenticate` endpoint with the user's credentials and the API will return a JSON
object,
with the user's profile information if requested.

### Request Parameters

| **Parameter** | **Optional** | **Type** | **Default** | **Description** |
|---------------|--------------|-----------|-------------|--------------------------------------|
| `username` | No | `str` | | The user's SRN or PRN |
| `password` | No | `str` | | The user's password |
| `profile` | Yes | `boolean` | `False` | Whether to fetch profile information |
| **Parameter** | **Optional** | **Type** | **Default** | **Description** |
|-------------------------------|--------------|-------------|-------------|-------------------------------------------------------------------------------------------------|
| `username` | No | `str` | | The user's SRN or PRN |
| `password` | No | `str` | | The user's password |
| `profile` | Yes | `boolean` | `False` | Whether to fetch profile information |
| `know_your_class_and_section` | Yes | `boolean` | `False` | Whether to fetch Know Your Class and Section information |
| `fields` | Yes | `list[str]` | `None` | Which fields to fetch from the profile information. If not provided, all fields will be fetched |

### Response Object

Expand Down Expand Up @@ -100,6 +103,7 @@ profile data was requested, the response's `profile` key will store a dictionary
| `phone` | Phone number of the user registered with PESU |
| `campus_code` | The integer code of the campus (1 for RR and 2 for EC) |
| `campus` | Abbreviation of the user's campus name |
| `error` | The error name and stack trace, if an error occurs |

#### KnowYourClassAndSectionObject

Expand All @@ -114,6 +118,7 @@ profile data was requested, the response's `profile` key will store a dictionary
| `department` | Abbreviation of the branch along with the campus of the user |
| `branch` | Abbreviation of the branch that the user is pursuing |
| `institute_name` | The name of the campus that the user is studying in |
| `error` | The error name and stack trace, if an error occurs |

<details><summary>Here is an example using Python</summary>

Expand All @@ -125,8 +130,9 @@ import requests
data = {
'username': 'your SRN or PRN here',
'password': 'your password here',
'profile': True # Optional, defaults to False
# Set to True if you want to retrieve the user's profile information
'profile': True, # Optional, defaults to False
'know_your_class_and_section': True, # Optional, defaults to False
'fields': None, # Optional, defaults to None to represent all fields
}

response = requests.post("http://localhost:5000/authenticate", json=data)
Expand Down Expand Up @@ -170,3 +176,29 @@ print(response.json())

</details>

<details><summary>Here is an example using cURL</summary>

#### Request

```bash
curl -X POST http://localhost:5000/authenticate \
-H "Content-Type: application/json" \
-d '{
"username": "your SRN or PRN here",
"password": "your password here"
}'
```

#### Response

```json
{
"status": true,
"message": "Login successful.",
"timestamp": "2024-07-28 22:30:10.103368+05:30"
}
```

</details>


0 comments on commit 1bfc6ba

Please sign in to comment.