botframework-solutions icon indicating copy to clipboard operation
botframework-solutions copied to clipboard

Getting Bad Request while testing Calendar Skill on Emulator

Open gagankohli2000 opened this issue 7 years ago • 10 comments

Hi,

I have deployed Calendar skill and while testing on Emulator I get login prompt. When i click on login prompt i get signin screen with bad request.

Please see the attached screenshot.

LoginError

gagankohli2000 avatar May 26 '19 09:05 gagankohli2000

Hi @gagankohli2000 could you check the issue #1419 and see if your problem is the same? If so, I would ask you to close this issue and follow up the other one, thanks!

dfavretto avatar May 27 '19 14:05 dfavretto

Thanks. I tried adding skill on Virtual Assistant and now getting following error. error

gagankohli2000 avatar May 28 '19 02:05 gagankohli2000

I have deployed skills and now accessing via virtual assistant. Still getting Bad Request when login with outlook login

gagankohli2000 avatar May 28 '19 03:05 gagankohli2000

Could you confirm the name of your oath connection name in appsettings.config (VA project) and the name of the oauth connection on your VA bot in the Azure Portal, they should match

darrenj avatar May 28 '19 06:05 darrenj

Here is the appsettings.json. I'm testing on Emulator "oauthConnections": [ { "provider": "Azure Active Directory v2", "name": "Outlook" } ] }

gagankohli2000 avatar May 28 '19 09:05 gagankohli2000

Here is Azure Portal screenshot oauth

gagankohli2000 avatar May 28 '19 09:05 gagankohli2000

Morning,

I've deployed a fresh copy of the Calendar Skill and followed this (new) instructions I'll merge into documentation later. Would be good to verify things match in your configuration. This is assuming you are using the skill directly, not via Virtual Assistant.

Out of interest. before you do this are you using a @outlook, @hotmail account or an o365 account (i.e. your employer?)

Authentication Connection Settings

If you plan to use the skill as part of a Virtual Assistant the process of registering a skill with your Virtual Assistant will create the supporting authentication connection information automatically for your Virtual Assistant. This skill uses the following authentication scopes which are registered automatically:

  • User.ReadBasic.All
  • Calendars.ReadWrite
  • People.Read
  • Contacts.Read

However, if you wish to use the Skill directly without using a Virtual Assitant please use the following steps to manually configure Authentication for the Calendar Skill. This is not required when using the Skill with a Virtual Assistant.

If you wish to make use of the Calendar, Email and Task Skills you need to configure an Authentication Connection enabling uses of your Assistant to authenticate against services such as Office 365 and securely store a token which can be retrieved by your assistant when a user asks a question such as "What does my day look like today" to then use against an API like Microsoft Graph.

The Add Authentication to your bot section in the Azure Bot Service documentation covers more detail on how to configure Authentication. However in this scenario, the automated deployment step has already created the Azure AD v2 Application for your Bot and you instead need to follow these instructions:

  • Navigate to the Azure Portal, Click Azure Active Directory and then App Registrations
  • Find the Application that's been created for your Bot as part of the deployment. You can search for the application by name or ApplicationID as part of the experience but note that search only works across applications currently shown and the one you need may be on a separate page.
  • Click API permissions on the left-hand navigation
    • Select Add Permission to show the permissions pane
    • Select Microsoft Graph
    • Select Delegated Permissions and then add each of the following permissions required for the Productivity Skills:
      • User.ReadBasic.All
      • Calendars.ReadWrite
      • People.Read
      • Contacts.Read
  • Click Add Permissions at the bottom to apply the changes.

Next you need to create the Authentication Connection for your Bot. Within the Azure Portal, find the Web App Bot resource created when your deployed your Bot and choose Settings.

  • Scroll down to the oAuth Connection settings section.
  • Click Add Setting
  • Type in the name of your Connection Setting - e.g. Outlook
  • Choose Azure Active Directory v2 from the Service Provider drop-down
  • Open the appSettings.config file for your Skill
    • Copy/Paste the value of microsoftAppId into the ClientId setting
    • Copy/Paste the value of microsoftAppPassword into the Client Secret setting
    • Set Tenant Id to common
    • Set scopes to User.ReadBasic.All, Calendars.ReadWrite, People.Read, Contacts.Read

Finally, open the appSettings.config file for your Calendar Skill and update the connection name to match the one provided in the previous step.

"oauthConnections": [
    {
      "name": "Outlook",
      "provider": "Azure Active Directory v2"
    }
  ],

darrenj avatar May 28 '19 10:05 darrenj

https://github.com/microsoft/botframework-solutions/blob/master/docs/reference/skills/productivity-calendar.md

darrenj avatar May 29 '19 08:05 darrenj

Thank Darren. Calendar skill is working independently now but when i run VA I'm still getting Bad Request error.

gagankohli2000 avatar May 29 '19 11:05 gagankohli2000

@gagankohli2000 - Out of interest, if you use the Calendar Skill directly using the Emulator are you able to authenticate OK? i.e. you don't get BadRequest? Only when using the Skill through VA?

darrenj avatar May 29 '19 12:05 darrenj