Pretty much working API authentication