/// <param name="token">An access token</param>
        /// <returns>The scopes</returns>
        internal static IEnumerable <Scope> GetScopes(this IAccessToken token)
        {
            string scopes = token.GetClaimValue(Constants.Claims.SCOPE);

            if (string.IsNullOrEmpty(scopes))
            {
                return(new Scope[] { });
            }

            Scope[] scopesArray = scopes
                                  .Split(' ')
                                  .Select(scopeString => Scope.Parse(scopeString))
                                  .Where(x => x != null)
                                  .ToArray();
            return(scopesArray);
        }
        private static bool TryGetLongClaim(this IAccessToken token, string claim, out long val)
        {
            string str = token.GetClaimValue(claim);

            return(long.TryParse(str, out val));
        }
 /// <param name="token">An access token</param>
 /// <returns>The tenant id. Returns null if one was not found.</returns>
 public static string GetTenantId(this IAccessToken token)
 {
     return(token.GetClaimValue(Constants.Claims.TENANT_ID));
 }
 /// <param name="token">An access token</param>
 /// <returns>The access token id. Returns null if one was not found.</returns>
 internal static string GetAccessTokenId(this IAccessToken token)
 {
     return(token.GetClaimValue(Constants.Claims.TOKEN_ID));
 }