WIP, porting behaviour from node client, validateToken method complete, now need to do the same for obtain token