Skip to content

Commit

Permalink
Use Token API to exchange the client's secret for a token
Browse files Browse the repository at this point in the history
  • Loading branch information
pcostantini committed Apr 5, 2017
1 parent 96023e4 commit 3bc4bfb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions CSharp/core-DirectLineWebSockets/DirectLineClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ public static void Main(string[] args)

private static async Task StartBotConversation()
{
var directLineClient = new DirectLineClient(directLineSecret);

// Obtain a token using the Direct Line secret
var tokenResponse = await new DirectLineClient(directLineSecret).Tokens.GenerateTokenForNewConversationAsync();

// Use token to create conversation
var directLineClient = new DirectLineClient(tokenResponse.Token);
var conversation = await directLineClient.Conversations.StartConversationAsync();

using(var webSocketClient = new WebSocket(conversation.StreamUrl))
using (var webSocketClient = new WebSocket(conversation.StreamUrl))
{
webSocketClient.OnMessage += WebSocketClient_OnMessage;
webSocketClient.Connect();
Expand Down Expand Up @@ -100,10 +103,11 @@ private static void WebSocketClient_OnMessage(object sender, MessageEventArgs e)
}
}
}

Console.Write("Command> ");
}
}

private static void RenderHeroCard(Attachment attachment)
{
const int Width = 70;
Expand Down

0 comments on commit 3bc4bfb

Please sign in to comment.