We are about to create an API so that our customers can connect to us, subscribe to a service and then consume that service. what is the best way to implement this? we work in C#, .NET. We want something like this:
we will provide a username and password to our customer to connect with our API. (how to implement this, using database?)?
after successful connection , customer will subscribe to our service. (how to check that customer is already connected? )
after subscription customer can calls API methods.
kindly tell me the best way.
A simple solution is to supply a Login method, your customers must call this one with username and password before consume the service, you can issue a token to the client once username/password validated, usually stored in a database; then the client can call your API method with the token attached for each request so you can check whether the client has called Login method or not; the token will be destroyed after the client finished using service by either providing a Logout method or setting up a expire time for each token.
This is for your consideration. About “best” way, I think there’s no such one way best for all situation. You will find the best way for you.