Skip to content
Lucas Oliveira edited this page Nov 15, 2020 · 1 revision

What is JWT.Service?

It's a simple way for you to generate tokens and authenticate using JWT.

What's in this package?

JWT.Service implements a static method for generating tokens, making your code leaner. In this method, the secret key of your application that will later authenticate in the token is passed as a parameter.

GenerateToken

In this method you are required to pass the user ID, the application's secret key and the token expiration time in hours as a parameter.

Example:

TokenService.GenerateToken (user.Id.ToString (), "CHAVESEC52", 6);

Authentication

In this method, it is required that you pass the application service in the API as a parameter, located in the Startup.cs class and the secret key for the respective authentication. It is also possible to pass some additional parameters for authentication of the token which is at the discretion of the developer.

Example:

JWTService.Authentication (services, "CHAVESEC52");

Clone this wiki locally