updating for latest JWK; relaxing redirect requirements; some generalization