{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4880","repository_url":"https://api.github.com/repos/Microsoft/BotBuilder","labels_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4880/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4880/comments","events_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4880/events","html_url":"https://github.com/Microsoft/BotBuilder/issues/4880","id":342887442,"node_id":"MDU6SXNzdWUzNDI4ODc0NDI=","number":4880,"title":"AADv2 Magic Code Not Returning Token From GetUserTokenAsync","user":{"login":"adamhockemeyer","id":20075292,"node_id":"MDQ6VXNlcjIwMDc1Mjky","avatar_url":"https://avatars3.githubusercontent.com/u/20075292?v=4","gravatar_id":"","url":"https://api.github.com/users/adamhockemeyer","html_url":"https://github.com/adamhockemeyer","followers_url":"https://api.github.com/users/adamhockemeyer/followers","following_url":"https://api.github.com/users/adamhockemeyer/following{/other_user}","gists_url":"https://api.github.com/users/adamhockemeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/adamhockemeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamhockemeyer/subscriptions","organizations_url":"https://api.github.com/users/adamhockemeyer/orgs","repos_url":"https://api.github.com/users/adamhockemeyer/repos","events_url":"https://api.github.com/users/adamhockemeyer/events{/privacy}","received_events_url":"https://api.github.com/users/adamhockemeyer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-19T20:59:41Z","updated_at":"2018-07-19T23:48:19Z","closed_at":null,"author_association":"NONE","body":"## Bot Info\r\n* SDK Platform: .Net\r\n* SDK Version: 3.15.3\r\n* Active Channels: Web Chat, Twilio\r\n* Deployment Environment: Azure App Service, Local Development\r\n\r\n## Issue Description\r\nI followed the [AADv2bot](https://github.com/Microsoft/BotBuilder/tree/master/CSharp/Samples/AadV2Bot) guide and created a bot, have it connected to AADv2, published to both Azure App Service and testing it locally.  The bot is also successfully connected to the Twilio channel.\r\n\r\nThe bot both locally and via Azure App Service with the web channel will present the \"Sign In\" button card, prompt for me to enter my credentials and will successfully call the MS Graph and return my name.\r\n\r\nTwilio however will send a long url for me to copy and paste into a browser, I then sign in via the browser and receive a 6 digit 'magic code' and enter that magic code back into the sms message back to the bot.  However I am never authenticated with the magic code.  I tried debugging this locally and manually calling `await context.GetUserTokenAsync(ConnectionName, MagicCode)` and it just results null.\r\n\r\nIn a breakpont that I set, the `GetTokenResponse` has `null` for `Token` and the magic code value I entered in as the `NonTokenRepsonse`.  It appears the `GetUserTokenAsync` with the magic code is not working correctly.\r\n\r\n[Here](https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Builder/Dialogs/GetTokenDialog.cs#L132) I believe is the line of code returning the magic code back to me and not a token.\r\n\r\n## Code Example\r\n\r\n```\r\nprivate async Task ListMe(IDialogContext context, IAwaitable<GetTokenResponse> tokenResponse)\r\n        {\r\n            var token = await tokenResponse;\r\n\r\n            // Twilio SMS using Magic Code hits below but will not return a token.\r\n            if(token.NonTokenResponse != null)\r\n            {\r\n               var result =  await context.GetUserTokenAsync(ConnectionName, token.NonTokenResponse);\r\n                // result is null when using magic code, the 'GetTokenDialog' calls this itself, but I was just verifying the value\r\n                if(result != null)\r\n                {\r\n                    token.Token = result.Token;\r\n                }\r\n               \r\n            }\r\n            \r\n            var client = new SimpleGraphClient(token.Token);\r\n\r\n            var me = await client.GetMe();\r\n            //var manager = await client.GetManager();\r\n\r\n            await context.PostAsync($\"Hello {me.DisplayName}!  You are signed in!\");\r\n        }\r\n```\r\n\r\n\r\n## Reproduction Steps\r\n1. Run this example: https://github.com/Microsoft/BotBuilder/tree/master/CSharp/Samples/AadV2Bot\r\n2. Connect it to Twilio as an additional channel\r\n3. Send 'me' in a text message to the SMS number setup and connected to the bot framework.\r\n4. You will receive a long url to copy and put into your browser to authenticate\r\n5. After authentication you will receive a 6 digit code\r\n6. Enter the code back into SMS to the Twilio SMS number.\r\n7. The `GetTokenResponse` will not contain a token, just a `NonTokenRepsonse` which is the code that was entered in.\r\n8. Unable to call the MS Graph client without a token.\r\n\r\n## Expected Behavior\r\nI would expect that the GetUserTokenAsync which accepts the connection name and magic code would return a token per this line (https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Builder/Dialogs/GetTokenDialog.cs#L116).\r\n\r\n## Actual Results\r\nInstead of returning a token when using the magic code a `GetTokenRepsonse` is returned where `Token` is `null` and `NonTokenResponse` contains the magic code that was entered into the text message."},"comment":{"url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/comments/406447355","html_url":"https://github.com/Microsoft/BotBuilder/issues/4880#issuecomment-406447355","issue_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/4880","id":406447355,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjQ0NzM1NQ==","user":{"login":"JasonSowers","id":6301037,"node_id":"MDQ6VXNlcjYzMDEwMzc=","avatar_url":"https://avatars3.githubusercontent.com/u/6301037?v=4","gravatar_id":"","url":"https://api.github.com/users/JasonSowers","html_url":"https://github.com/JasonSowers","followers_url":"https://api.github.com/users/JasonSowers/followers","following_url":"https://api.github.com/users/JasonSowers/following{/other_user}","gists_url":"https://api.github.com/users/JasonSowers/gists{/gist_id}","starred_url":"https://api.github.com/users/JasonSowers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasonSowers/subscriptions","organizations_url":"https://api.github.com/users/JasonSowers/orgs","repos_url":"https://api.github.com/users/JasonSowers/repos","events_url":"https://api.github.com/users/JasonSowers/events{/privacy}","received_events_url":"https://api.github.com/users/JasonSowers/received_events","type":"User","site_admin":false},"created_at":"2018-07-19T23:48:19Z","updated_at":"2018-07-19T23:48:19Z","author_association":"MEMBER","body":"@adamhockemeyer  thanks for reporting this I have not tried Twilio myself yet, I will work on getting a reproduction set up and will report back with any information or possible workaround I find."}}
{"actor":{"display_login":"JasonSowers"}}