Search code examples
oauthbotframeworkazure-bot-service

403 Forbidden Error when attempting to authenticate


I cloned and ran 24.bot-authentication-msgraph to test authentication. I've updated the .bot file to put my app id and password as found https://apps.dev.microsoft.com. I've also updated CONNECTION_SETTING_NAME variable in bot.js.

Edit: I forked the repo so you can see my code and changes here. Check out the last 3 commits to see my changes. I excluded my .bot file because it has my app password.

But the bot doesn't even try to authenticate me, and in the console, I received a 403 error. It has no description or text with it.

enter image description here


Solution

  • Alright, after doing some troubleshooting and intentionally trying to break my implementation, I figured out the issue.

    You have two "apps", 1 "App Registration" in the App Registration Portal and 1 "Web App Bot/Bot Channels Registration" in your Azure Resource Group (or at least you should if you follow the docs):

    1. An Azure AD v1 or v2 app created in this step "To create an Azure AD v1/v2 application"
    2. A Bot Channels Registration app created in this step "Create your bot on Azure"

    Based on your images, you're using your Azure AD v2 appId and appPassword in your .bot file, when you should be using your Bot Channels Registration bot's appId and appPassword, as described in this step.

    Note: The Azure AD v2 appId and appPassword are only used when editing your bot's Azure settings to add OAuth.

    You can get your bot's appId and appPassword (which you need to place in your .bot file) in either of two ways:

    • Via App Registration Portal
      1. Go to the App Registration Portal and click on your bot (NOT the Azure AD v1/v2 app).
        • If you named them similarly, you'll know you chose the wrong one if it has a Web Platform listed--that should only be in the Azure AD v1/v2
      2. It will list your appId and you can get a new password by clicking "Generate New Password"

    or,

    • Via Azure Portal
      1. Open your Resource Group in the Azure portal.
      2. Click Deployments
      3. Under "Deployment Name", click your Bot Channels Registration bot.
      4. Click Inputs. Your appId and appPassword is APPID and APPSECRET, respectively.