AzureFunctions.Authentication.FrontEndAuthProvider.ParsePortalToken C# (CSharp) Method

ParsePortalToken() private method

private ParsePortalToken ( string portalToken ) : AzureFunctions.Authentication.AzureFunctionsPrincipal
portalToken string
return AzureFunctions.Authentication.AzureFunctionsPrincipal
        private AzureFunctionsPrincipal ParsePortalToken(string portalToken)
        {
            if (string.IsNullOrEmpty(portalToken))
            {
                throw new ArgumentException($"{nameof(portalToken)} cannot be null or empty.");
            }

            var jwt = new JwtSecurityToken(portalToken);

            var principalName = jwt.Claims.FirstOrDefault(c => c.Type == Email)?.Value ?? jwt.Claims.FirstOrDefault(c => c.Type == UniqueName)?.Value;
            var displayName = jwt.Claims.FirstOrDefault(c => c.Type == Name)?.Value ?? jwt.Claims.FirstOrDefault(c => c.Type == GivenName)?.Value;

            return new AzureFunctionsPrincipal(new AzureFunctionsIdentity(principalName ?? displayName));
        }