Example #1
0
        /// <summary>
        /// Get access token for accessing the resource.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="forceRefresh"></param>
        /// <returns>Access token as an awaitable Task.</returns>
        public async Task <string> GetToken(string key, bool forceRefresh)
        {
            var token = await botData.GetTokenAsync(this.authOptions, this.authProvider, CancellationToken.None);

            if (token == null)
            {
                await botData.LogoutAsync(this.authProvider, CancellationToken.None);
            }
            return(token);
        }
 /// <summary>
 /// Prepare by getting access token from Azure Active Directory.
 /// </summary>
 /// <param name="item">Activity item</param>
 /// <param name="token">Cancellation token</param>
 /// <returns>Token string as an awaitable task.</returns>
 protected override async Task <string> PrepareAsync(IActivity item, CancellationToken token)
 {
     return(await _botData.GetTokenAsync(this.authOptions, this.authProvider, token));
 }