Token-based authentication
any application can authenticate and use any feature in the application as an API. For example, you can create a mobile application that consumes the same API. In this section, we will demonstrate the use of the API (Google Chrome extensions) from Postman.
Certifications
We recommend that you disable two-factor authentication for users who are using Remote authentication. Otherwise, the client should implement two factor authentication processes. We assume that you have an administrator user for the default tenant Two-factor authentication is disabled because we will use it in this example.
The following headers should be configured for all requests (Abp.tenantid is the ID of the default tenant), which is not required for a single tenant application, or if you want to work with host users):
then we can send the user name and password as POST request to/HTTP/localhost:62114 /api/tokenauth/authenticate
in the returned response, the Accesstoken will be used for the authorization API.
using the API
after validating and obtaining an access token, we can use it to invoke any authorized operation. all Services can be used remotely. For example, we can use User Services to get a list of users :
we sent a GET request to HTTP. localhost:62114/api/services/app/user/getusers and added the title as " Bearer <accessToken> ". returns the JSON containing list of users.
SWAGGER UI
The SWAGGER UI is integrated into ASP. NET zero, but is disabled by default . The Swagger UI configuration is located in the S Tartup class in the. Web Project . You can enable it by uncomment the related line:
in the Start Configureservices method, enable the following line:
Services. Addswaggergen ();
And in the Startup.configure method, enable the following line:
app. Useswagger (); app. Useswaggerui ();
You can Use this URL Browse Swagger UI: "/ swagger/ui ".
As a result, anyone (or any application) can easily explore, test, and use the API??。
ASP. zero--Token-based authentication &swagger UI