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

oAuthPrompt has an invalid value/link on Bot Emulator v4.5.2 #1756

Closed
textminer opened this issue Aug 20, 2019 · 5 comments
Closed

oAuthPrompt has an invalid value/link on Bot Emulator v4.5.2 #1756

textminer opened this issue Aug 20, 2019 · 5 comments
Labels
Bot Services equired for internal Azure reporting. Do not delete. Do not change color. Bug Your classic code defect customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete.

Comments

@textminer
Copy link

textminer commented Aug 20, 2019

Related to:
#1006
microsoft/BotBuilder-Samples#728

Version

v4.5.2

Describe the bug

Invoking OAuthCards on Bot Emulator results in InvalidAuthenticationToken, with CompactToken parsing failed with error code: 80049217.
OAuthCard Connection String has been tested on Azure and results ok.

To Reproduce

  1. I registered an Azure AD v2 app to be used for my bot
  2. I tested the connection settings from the bot and resulted ok
  3. Tried OAuthCards on MS Teams and resulted ok. (got a valid access token to consume MS Graph Api)
  4. If I run it on the Emulator: I get:
    InvalidAuthenticationToken, with CompactToken parsing failed with error code: 80049217.
    Token received is an authorization token rather than an access token. Also, noticed that the link created on the emulator does not look correct as seen at:
    oAuthPrompt has an invalid value/link #1006
  1. Is reproducible with and without "Bypass ngrok for local addresses"

Source Code being used
// Create a DialogSet that contains the OAuthPrompt.
this.dialogSet = new DialogSet(this.dialogState);

    // Add an OAuthPrompt with the connection name as specified on the Bot's settings blade in Azure.
    //this.dialogSet.add(this.prompt(process.env.OAUTH_CARDS_CONNECTION_STRING));
    this.oauthPrompt = new OAuthPrompt(LOGIN_PROMPT,
        {
            connectionName: process.env.OAUTH_CARDS_CONNECTION_STRING,
            text: 'Please login into SharePoint',
            title: 'Login',
            timeout: 10000
        });
    
    this.dialogSet.add(this.oauthPrompt);

...
await step.context.sendActivity(Your token is: ${ tokenResponse.token });

Expected behavior

A valid access token should be received for querying the MS Graph API.

Screenshots

imagen

Bot Emulator settings
imagen

Additional context

Same source code works fine in MS Teams. It returns a valid Bearer Token.
My only suspicion is that I do not put MsAppPassword in .ENV

[bug]

@tonyanziano
Copy link
Contributor

tonyanziano commented Aug 20, 2019

Hi @textminer ,

Thanks for the detailed issue report!

From the looks of your screenshots it appears that the Emulator has fallen back to providing you with an emulated token and not a genuine token from the Bot Framework token service.

This happens when the Emulator fails to generate a valid OAuth signin link. This can be caused by several things, but usually is due to an incorrect path to ngrok in the settings page, but it looks like you have that configured.

I currently have a pull request (#1745) out that will add error logging to this flow, so the Emulator will tell you why it is falling back to generating an emulated token. Once this PR gets merged in (hopefully by the end of day), we will release a new nightly version of the Emulator tonight with the change.

It would be great if you could use that nightly version (will be available here once it has been released) and try this same scenario so we can see the error message that is causing this.

Also, I believe you need to have the correct Microsoft App ID & Password passed into your bot code as well as into the Emulator when connecting to your bot.

@tonyanziano tonyanziano added customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete. Bot Services equired for internal Azure reporting. Do not delete. Do not change color. labels Aug 20, 2019
@textminer
Copy link
Author

textminer commented Aug 20, 2019

Hi @tonyanziano,

I made sure the Microsoft App ID & Password are correct doing a POST using POSTMAN as explained at https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-authentication?view=azure-bot-service-4.0
I tried with and without putting those keys in the .env file.

Thanks for putting hands on it. I'll let you know the outcomes with the new nightly version.

@tonyanziano
Copy link
Contributor

@textminer the PR has been merged in, so the nightly should become available shortly after 10 PM PST tonight (Usually around 10:30 PM PST).

@textminer
Copy link
Author

Hi, I installed the night built, and as seen in the pic below I had an Unauthorized issue between the Emulator and the Bot. Now the Emulator shows it.
imagen
The solution was to recreate the .bot file config that the Emulator uses and it started being authorized and getting a valid access token. I must have been reusing the same .bot file in the emulator created with previous versions...

Thanks all for your support.

@tonyanziano
Copy link
Contributor

Awesome! Glad you got it figured out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services equired for internal Azure reporting. Do not delete. Do not change color. Bug Your classic code defect customer-replied-to Required for internal reporting. Do not delete. customer-reported Required for internal Azure reporting. Do not delete.
Projects
None yet
Development

No branches or pull requests

2 participants