Skip to content

ITokenService

Namespace: Rest_API.Services.Token

Service responsible for generating JWT access and refresh tokens.

public interface ITokenService

Methods

GenerateAccessToken(IEnumerable<Claim>)

Generates a JWT access token containing the specified claims.

string GenerateAccessToken(IEnumerable<Claim> claims)

Parameters

claims IEnumerable<Claim>

Claims to include in the token.

Returns

JWT access token as a string.

GenerateRefreshToken()

Generates a secure random refresh token.

string GenerateRefreshToken()

Returns

Refresh token as a base64 string.

GetPrincipalFromExpiredToken(String)

Retrieves the claims principal from an expired access token.

ClaimsPrincipal GetPrincipalFromExpiredToken(string accessToken)

Parameters

accessToken String

The expired access token.

Returns

Claims principal containing the token's claims.