Code authentication

Fix #144 
Fix #139