Use one application token per thread

This change prevents fetching new application token on each request
that uses one. Now one token is user per thread, and new token is
requested only when the previous one is expired or the application
was restarted.