Ejemplo n.º 1
0
        static void GetRefreshToken_Good()
        {
            var authClient  = new HubsterAuthClient(OnAuthRequest, "http://*****:*****@email.com", "Password123!");

            apiResponse = authClient.EnsureLifespan(apiResponse.Token);
        }
Ejemplo n.º 2
0
        static void EnsureLifeSpan_Good()
        {
            var authClient  = new HubsterAuthClient(OnAuthRequest, "http://localhost:5000");
            var apiResponse = authClient.EnsureLifespan();

            if (apiResponse.StatusCode == HttpStatusCode.OK)
            {
                apiResponse = authClient.EnsureLifespan(apiResponse.Token);
            }
        }
Ejemplo n.º 3
0
        public static void Run()
        {
            var auth       = new HubsterAuthClient(OnAuthorizationRequest, "http://localhost:5000");
            var authorizer = new HubsterAuthorizer(auth);

            // EstablishConversation(authorizer);
            // GetEstablishedConversation(authorizer);
            // GetActivities(authorizer);
            // SendActivityToAgent(authorizer);
            SendActivityToCustomer(authorizer);
        }
Ejemplo n.º 4
0
        public static void Run()
        {
            var origin = "http://localhost";

            var auth = new HubsterAuthClient(hostUrl: "http://host.docker.internal:5000", onAuthRequest: (authClient) =>
            {
                // typically this will be a call to some backend service that will return back the token
                var apiResponse = authClient.GetClientToken("hubster.engine.api.00000000000000000000000000000001", "9c5Vbnd0vZGlqTdBzhz9hb9cQ0M=");
                return(apiResponse);
            });

            // var auth = new HubsterAuthWebChat(_integrationId, origin, "http://host.docker.internal:5002");
            var client     = new HubsterDirectClientCustomer(origin, "http://host.docker.internal:5002", "http://host.docker.internal:5005");
            var authorizer = new HubsterAuthorizer(auth);

            while (true)
            {
                var startChatting = Commands(authorizer, client);
                if (startChatting == false)
                {
                    return;
                }

                Console.Clear();
                var username = GetUserName(_lastConverstion);

                var eventResponse = client.Events.Start(options =>
                {
                    options.Authorizer     = authorizer;
                    options.Origin         = origin;
                    options.IntegrationId  = _lastConverstion.IntegrationId.Value;
                    options.ConversationId = _lastConverstion?.ConversationId;
                    options.OnActivity     = (activity) => Display(activity);
                    options.OnConnected    = () => Display("Connected", ConsoleColor.Cyan);
                    options.OnDisconnected = () => Display("Disconnected", ConsoleColor.Yellow);
                    options.OnError        = (error) => Display(error.Description, ConsoleColor.Yellow);
                });

                if (eventResponse.StatusCode != HttpStatusCode.OK)
                {
                    Display(eventResponse);
                    Console.ReadKey();
                    return;
                }

                ConversationLoop(authorizer, client, _lastConverstion, username);

                client.Events.Stop(eventResponse.Content);
            }
        }
Ejemplo n.º 5
0
        static IdentityResponse <IdentityToken> OnAuthorizationRequest(HubsterAuthClient client)
        {
            var apiResponse = client.GetClientToken("hubster.engine.api.00000000000000000000000000000001", "9c5Vbnd0vZGlqTdBzhz9hb9cQ0M=");

            return(apiResponse);
        }
Ejemplo n.º 6
0
        static IdentityResponse <IdentityToken> OnAuthRequest(HubsterAuthClient client)
        {
            var apiResponse = client.GetUserToken("*****@*****.**", "Password123");

            return(apiResponse);
        }
Ejemplo n.º 7
0
 static void GetUserToken_BadGrant()
 {
     // need to change the grant_type in the IdentitAccess class to test this.
     var authClient  = new HubsterAuthClient(OnAuthRequest, "http://*****:*****@email.com", "Password123!");
 }
Ejemplo n.º 8
0
 static void GetClientToken_BadCreds()
 {
     var authClient  = new HubsterAuthClient(OnAuthRequest, "http://localhost:5000");
     var apiResponse = authClient.GetClientToken("unknown", "unknown");
 }
Ejemplo n.º 9
0
 static void GetClientToken_Good()
 {
     var authClient  = new HubsterAuthClient(OnAuthRequest, "http://localhost:5000");
     var apiResponse = authClient.GetClientToken("hubster.engine.api.00000000000000000000000000000001", "9c5Vbnd0vZGlqTdBzhz9hb9cQ0M=");
 }