Class TokenService
- Namespace
- Dynamicweb.Security.Tokens
- Assembly
- Dynamicweb.Core.dll
Service to working with tokens.
- Inheritance
-
Token
Service
- Inherited Members
Methods
AuthenticateToken(string, string?)
Authenticates the given token. If the token is valid, the related user is returned.
Parameters
Returns
GetToken(int)
Returns the Token with the given id.
Parameters
id
intThe id of the token to get.
Returns
- Token
The token matching the id if it exists;
null
otherwise.
GetToken(string, string?)
Parameters
Returns
GetTokens()
Returns a list of all Tokens.
Returns
- IEnumerable<Token>
List of all tokens.
RevokeToken(int)
Revokes the token with the given id.
Parameters
id
intThe id of the token to revoke.
Returns
- bool
true
if the token was revoked;false
otherwise.
Save(Token)
Saves the given Token. This method cannot be used to create a new token.
Parameters
token
TokenThe token to save.
Returns
- bool
true
if the token was saved;false
otherwise.
Exceptions
- Invalid
Operation Exception If the given token doesn't already exist.
TryCreateToken(ApiTokenRequestModel, User)
Tries to create a Token from the given Api
Parameters
tokenRequest
ApiToken Request Model The request to create
user
UserThe user that is creating the API Token.
Returns
- string
Unhashed token if creation was successful;
null
otherwise.
TryCreateToken(TokenRequestModel)
Tries to create a Token from the given Token
Parameters
tokenRequest
TokenRequest Model The request to create
Returns
- string
Unhashed token if creation was successful;
null
otherwise.