Do not ask for a System User Ticket every single time you invoke an Agent method! This is a performance penalty. Take advantage of the 6-hour window and only ask for a new Ticket when absolutely necessary!
SystemUserClient
Use theSystemUserClient class, located in the SuperOffice.WebApi.IdentityModel namespace.
The constructor accepts a SystemUserInfo instance and contains all of the information required to submit a request to the partnersystemuserservice.svc endpoint.
SystemUserInfo properties
Generate and send request
Given the required information, theSystemUserClient can generate and send a request to the service, then receive and validate the response.
SystemUserResult. It does not validate or extract any claims.
The GetSystemUserTicketAsync, validates the returned JWT, populates the SystemUserClient.ClaimsIdentity property, and returns the SOTicket credential.
JWT validation
GetSystemUserTicketAsync is what consumers will use 99.9 percent of the time, but if there is a desire to skip the convenience, there are two alternatives for performing JWT validation.
Alternative 1:
Use the ValidateSystemUserResult method, and get back a TokenValidationResult.
This method also populates the SystemUserClient.ClaimsIdentity property. This method is used by GetSystemUserTicketAsync.
SystemUserClient uses the JwtTokenHandler, located in the SuperOffice.WebApi.IdentityModel namespace.
SystemUserTokenHandler.ValidateAsync method returns a TokenValidationResult, a Microsoft datatype located in the Microsoft.IdentityModel.JsonWebTokens namespace, in the Microsoft.IdentityModel.JsonWebTokens assembly.