function to get the token, checking if it is valid (which I still need to think about)