Botframework-emulator: oAuthPrompt has an invalid value/link on Bot Emulator v4.5.2

Created on 20 Aug 2019  路  5Comments  路  Source: microsoft/BotFramework-Emulator

Related to:
https://github.com/Microsoft/BotFramework-Emulator/issues/1006
https://github.com/Microsoft/BotBuilder-Samples/issues/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:
    https://github.com/Microsoft/BotFramework-Emulator/issues/1006
    5) 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]

Bot Services Bug customer-replied-to customer-reported

All 5 comments

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.

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.

@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).

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.

Awesome! Glad you got it figured out.

Was this page helpful?
0 / 5 - 0 ratings