Api authentication

Fixes #57 and fixes #76