Auth json 2

an update of #650 for the latest master