Exemplo n.º 1
0
        /// <summary>
        /// Creates a Bot client that connects itself to the api gateway
        /// </summary>
        /// <returns></returns>
        private async Task <GatewayClient> CreateExternalClient()
        {
            var config = GetConfig();
            var info   = new GatewayInformation(config);


            var clientInfo = new ClientInformation()
            {
                Credentials = new ClientCredentials()
                {
                    ClientId     = info.ExternalClientInfo.ClientId,
                    ClientSecret = info.ExternalClientInfo.ClientSecret
                },
                TargetApiName      = info.GatewayApiName,
                TargetBaseUrl      = info.GatewayApiBaseUrl,
                AuthServerLocation = info.AuthServerUrl
            };
            var clientInfoOptions = new OptionsWrapper <ClientInformation>(clientInfo);

            var client        = new GatewayClient(clientInfoOptions, new MockLoggerFactory <object>());
            var tokenResponse = await GetAccessTokenFromAuthServer(clientInfo);

            client.SetBearerToken(tokenResponse.AccessToken);

            return(client);
        }