public static Guid?GetToken(this IOwinRequest request)
        {
            string token = request.Query.Get("token") ?? request.GetBasicAuthorization();

            if (token == null)
            {
                return(null);
            }

            Guid guid;

            if (Guid.TryParse(token, out guid))
            {
                return(guid);
            }

            throw new InvalidTokenFormatException();
        }