This documentation provides an overview of the SimpleAuthNet API, an authentication and authorization system built with ASP.NET using .NET 8.
Registers a new user.
URL: /User/Register
Method: POST
Request Body:
{
"email": "[email protected]",
"password": "password123"
}
Response:
{
"isSucceed": true,
"messages": {},
"data": true
}
Authenticates a user and returns an access token and refresh token.
URL: /User/Login
Method: POST
Request Body:
{
"email": "[email protected]",
"password": "password123"
}
Response:
{
"isSucceed": true,
"messages": {},
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "abc123..."
}
}
Refreshes the access token using a refresh token.
URL: /User/RefreshToken
Method: POST
Request Body:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "abc123..."
}
Response:
{
"isSucceed": true,
"messages": {},
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "def456..."
}
}
Logs out the currently authenticated user.
URL: /User/Logout
Method: POST
Response:
{
"isSucceed": true,
"messages": {},
"data": true
}
Retrieves the profile information of the authenticated user.
URL: /User/Profile
Method: POST
Headers:
Authorization: Bearer <access_token>
Response:
Retrieves a weather forecast.
URL: /api/WeatherForecast
Method: GET
Headers:
Authorization: Bearer <access_token>
Response:
[
{
"date": "2023-06-01T00:00:00",
"temperatureC": 25,
"summary": "Warm"
},
...
]
To build the SimpleAuthNet project using the dotnet
CLI, follow these steps:
-
Ensure that you have the .NET SDK installed on your machine. You can download it from the official Mixcrosoft website: .NET SDK
-
Clone this repository to your local machine using the following command:
git clone [repository_url]
-
Open a terminal or command prompt and navigate to the root directory of the SimpleAuthNet project:
cd SimpleAuthNet
-
Run the following command to restore the project dependencies:
dotnet restore
-
Once the dependencies are restored, run the following command to build the project:
dotnet build
This command will compile the project and generate the output in the
bin
directory. -
(Optional) If you want to run the tests, use the following command:
dotnet test
This will execute the unit tests defined in the project.
-
To run the application, use the following command:
dotnet run
This will start the application, and you can access it via the specified URL (e.g.,
http://localhost:5023
).
That's it! You have now successfully built and run the SimpleAuthNet project using the dotnet
CLI.