/// <summary>
        /// See if we already have an access token cache for the user, otherwise create a new one.
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public static AccessTokens AccessTokensForToken(OpenIdToken token)
        {
            AccessTokens value;
            if (!GlobalTokenCache.TryGetValue(token.UserId, out value) || null == value)
            {
                // Create a new one and add to cache
                value = new AccessTokens(token);
                GlobalTokenCache[token.UserId] = value;
            }

            return value;
        }
        /// <summary>
        /// See if we already have an access token cache for the user, otherwise create a new one.
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public static AccessTokens AccessTokensForToken(OpenIdToken token)
        {
            AccessTokens value;

            if (!GlobalTokenCache.TryGetValue(token.UserId, out value) || null == value)
            {
                // Create a new one and add to cache
                value = new AccessTokens(token);
                GlobalTokenCache[token.UserId] = value;
            }

            return(value);
        }
示例#3
0
        protected async void buttonGetAccessToken_Click(object sender, EventArgs e)
        {
            bool useDogfood        = UseDogfoodEnvironemnt(Request, Response);
            var  targetResourceUri = textBoxResourceUri.Text;
            var  storedToken       = Utility.TokenStore.TokenFromCookie(Request.Cookies);

            try
            {
                Models.AccessTokens tokenCache = Models.AccessTokens.AccessTokensForToken(storedToken);
                var token = await tokenCache.GetAccessTokenForResourceAsync(targetResourceUri, useDogfood);

                accessToken.Text = token;
            }
            catch (Exception ex)
            {
                accessToken.Text = ex.ToString();
            }
        }