subroutine to authenticate users by API token