예제 #1
0
        /// <summary>
        /// Check whether access_token cache is created and stores if not.
        /// </summary>
        async Task <string> GetTokenCache()
        {
            var tokenCache = (Token)HttpContext.Cache.Get("access_token");

            if (tokenCache == null)
            {
                tokenCache = await ApiEvents.GetToken();

                HttpContext.Cache.Add("access_token", tokenCache, null, DateTime.Now.AddSeconds(tokenCache.expires_in),
                                      Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal, null);
            }
            return(tokenCache.access_token);
        }