Added support for token caching and refresh