Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token not being cached for bot authentication with users and magic numbers don't work #4899

Closed
Rykimaruh opened this issue Jul 24, 2018 · 12 comments
Assignees

Comments

@Rykimaruh
Copy link

Rykimaruh commented Jul 24, 2018

Hello,

I am getting the same problem as my previous one with token no caching as it should. This happens in the emulator though. It was able to hold the cached token before, but now it doesn't. This happened before the following issue happened.

The other issue is that whenever I paste the authentication number to chat, the bot tells me an error message as follow:

image

@Rykimaruh Rykimaruh changed the title Token not being cached again Token not being cached again for bot authentication with users Jul 24, 2018
@Rykimaruh Rykimaruh changed the title Token not being cached again for bot authentication with users Token not being cached for bot authentication with users Jul 24, 2018
@Rykimaruh Rykimaruh changed the title Token not being cached for bot authentication with users Token not being cached for bot authentication with users and magic numbers don't work Jul 24, 2018
@JasonSowers
Copy link
Contributor

Are you using teams? If not what channel?

@Rykimaruh
Copy link
Author

@JasonSowers , yes I am using Teams

@JasonSowers
Copy link
Contributor

JasonSowers commented Jul 25, 2018

You have to type in the code for teams, copying and pasting will make the text input be like “\r\n804230\n” or something similar. I wrote a regex that can handle this programmatically I can post shortly.

@JasonSowers
Copy link
Contributor

JasonSowers commented Jul 25, 2018

This is just one way to handle this in your code. You could probably find a better way of doing this.

In my messages controller I put a check for the magic code copy paste like this:

            if (activity.Type == ActivityTypes.Message)
            {
                if (activity.ChannelId == ChannelIds.Msteams && activity.Text.StartsWith("\r\n"))
                {
                        activity.Text = CustomCode.SanatizeMagicCodeForTeams(activity.Text);
                }
                await Conversation.SendAsync(activity, () => new RootDialog());
            }

Then I wrote this simple static class to handle it:

    public static class CustomCode
    {
        public static string SanatizeMagicCodeForTeams(string magicCode)
        {
            Regex regex = new Regex(@"\r\n(\d{6})\n");
            var match = regex.Match(magicCode);
            if (match.Success)
            {
                magicCode = magicCode.Substring(2, 6);
            }
            return magicCode;
        }
    }

@JasonSowers
Copy link
Contributor

@Rykimaruh let me know if that helps

@JasonSowers JasonSowers self-assigned this Jul 25, 2018
@Rykimaruh
Copy link
Author

@JasonSowers it works! Thank you!

Were you able to check up on other issue pertaining the cached token and the emulator?

@JasonSowers
Copy link
Contributor

@Rykimaruh can you remind me which issue you are talking about specifically?

@Rykimaruh
Copy link
Author

"I am getting the same problem as my previous one with token no caching as it should. This happens in the emulator though. It was able to hold the cached token before, but now it doesn't. This happened before the following issue happened."

It would seem token caching is having issues again. Can this be verified?

@JasonSowers
Copy link
Contributor

JasonSowers commented Jul 25, 2018

Ahh yes, this issue resurfaced, it should be fixed now. Apologies, as I am trying to help resolve many Auth issues and I know I had been talking to you on other threads. Someone else pointed this out earlier and I was able to get the team to deploy a temporary fix until we have a more permanent one in our next release. When this happens, try to check another channel, if it doesn't happen on another channel it's an issue with the emulator and please let us know as you did.

If you start seeing trouble with the emulator and you have had it running for a while(~8 hours), restart the emulator. The emulator uses ngrok, and ngrok sessions expire after 8 hours.

@Rykimaruh
Copy link
Author

@JasonSowers , it was working for a short while, but it seems the issue came back once again.

@JasonSowers
Copy link
Contributor

It should be fixed again, it will be permanently fixed in our next deployment. Thanks for reporting.

@JasonSowers
Copy link
Contributor

Going to close this issue. Please open a new one if you experience anything else we can help with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants