added authentication

Let me know if this is correct and whether any changes need to be made, thanks (: