The application is a MVC/WebAPI 2 app written in c#. The app can be run in debug mode using visual studio.
- Clone the source from this repo
- Restore the NuGet packages
- Run the app
The application features a simple UI layer to access the API as it's homepage
The endpoints are documented in detail at /help
The applications has good coverage of NUnit tests for both the Product Service and API Endpoints. These can be run through the Visual Studio test runner.
Any endpoints that manipulate data (POST, PUT, DELETE) require a user to be authenticated. Authentication is handled by Token Based Authentication to better support API integration.
Tokens can be generated by sending a POST request to /token with the following data:
{
header: {
"Content-Type", "application/x-www-form-urlencoded"
},
body: "grant_type=password&username=user&password=pass"
}
This will return an Auth token with an expiry date of one day that can then be used to authenticate future requests.
For testing the credentials are:
username: admin password: Adm!NP%Ss
Once generated a token will be valid for one day. To authenticate send the following header with each request:
Authorization: "bearer TOKENHERE"
Tokens can also be generated through the UI by using the login box above the request form. This will save the token to the users local storage for subsequent requests.
When the token expires (after one day) the next request will cause the user to be logged out. Logging back in will reset the token for a further day.