Skip to content

swleighton/product-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Product API

Running the application

The application is a MVC/WebAPI 2 app written in c#. The app can be run in debug mode using visual studio.

  1. Clone the source from this repo
  2. Restore the NuGet packages
  3. Run the app

The application features a simple UI layer to access the API as it's homepage

Product EndPoints

The endpoints are documented in detail at /help

Running tests

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.

Authentication

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.

Generating Tokens

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

Using Tokens

Once generated a token will be valid for one day. To authenticate send the following header with each request: Authorization: "bearer TOKENHERE"

Tokens in the UI

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.

About

Simple C# Web API 2 Product CRUD App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published