Reply address configuration Issue in bot-authentication-msgraph code - c#

I am using a Microsoft Graph api code to authenticate and get details of user.
I am trying to build and run below project.
console csharp connect msgraph project
After building and running the project , it redirects to a browser and ask to login using my account and when i select my email account ,it shows the error (AADSTS500113 No reply address is registered for the application) in attached screenshot.
Please Help.

Go to apps.dev.microsoft.com
Click the "Edit Application Manifest" button.
Add https://yourdomain.com/callback to the replyUrls element.
For Azure AD
If this does not fix your problem you might have to look at Azure AD. I am not sure which solution you're looking for since your question was a bit decryptive formulated.

Related

How to really send a message to a user in Teams through a bot

The last few days, I checked dozens of samples, docs, blog posts, youtube videos (courses, that I couldn't fine) and I can say I'm still confused and I still without a Teams bot.
Every example I've checked is different in approach, and now I'm pretty sure there are many others like me.
Frequently problems: required input/parameters like service Url, conversation Id, etc. 1. You can't find a explanation for them. 2. You can't find a place where it's explained how to get them.
What I want to achieve
I want a bot on Teams, with a API, with 2 parameters: user email, message. The bot has to send the message to the specified user. That's it.
I'm looking how to:
Create/Setup the Application
Create the actual Bot
Install the application to Teams
I used to create a Teams conversation bot. Hope my experience will help you.
First, download sample provided by microsoft. I uses c# to create this bot, so I copy the '57.teams-conversation-bot' folder and opened it with vs studio. In this sample, I need to modify the configuration in appsettings.json. I need to enter the appid and apppassword.
So the next step is creating an Azure ad application in Azure portal. But if you never create Bot Framework registration resource before, you can create the azure ad application when you create a Bot Framework.By the way, You can leave 'Messaging endpoint' empty now. Please note, when you creating Azure ad application, you can choose to set this application as a multitenant app if your account creating the app is in a different tenant with your teams account.
Now I have a bot framework and an Azure ad app, I can modify appsettings.json, enter the appId and app password. I can get appId in app overview page and get app password when creating client secrets in Certificates & secrets tag.
Now, I need to debug my sample with web chat in the azure portal(Enter the bot framework created just now, you can see Tag 'Test in web chat' in the left panel). So I need to use ngrok to make the bot visit my code in local environment. Running the sample by pressing F5 in vs studio. Opening ngrok.exe and running the command ngrok http -host-header=rewrite 3978. Then I can get a https url, copy that and paste in the 'Messaging endpoint'. Don't forget to add '/api/messages'.
Now sending 'hello' to the bot and you will get default result. When you get the picture below, it means you have made a correct configuration.
Next step is to add this bot to Teams client. First, I add the Teams Channel in the bot I created in the azure portal.
Then I need to modify the manifest file. Replacing the "YOUR-MICROSOFT-APP-ID" with appId creating just now. And creating manifest.zip file which contains the three file in folder TeamsAppManifest.
Next step is uploading the zip file to Teams client. Click the 'Apps' in the lower-left corner and click the 'Upload the custom app' in the bottom of the left panel, then click add. Ok, now I get a team conversation bot.
There -are- a ton of approaches, partly because Teams development is still relatively new, partly because the Bot Framework (the set of tools for buildings Bots in the Microsoft world, both for Teams and otherwise) has also undergone some major changes. That's aside from the various language options (dotnet, node, python, etc.).
What's looking to be a good place to get started though, is the new Teams Toolkit, a plugin for Visual Studio and Visual Studio Code, for building a new Teams project (Tab, Bot, etc.). Have a look here for a link. It's very new though, so some rough edges, but it's aiming to be very comprehensive to get up and running quickly (does a lot of Azure registrations behind the scenes, for example). Check out the latest monthly Teams Developer call, from earlier this week, for a visual run-through: https://www.youtube.com/playlist?list=PLWZJrkeLOrbbTKzV1sQOFAXd_s0BHJDiL (this week's call isn't up yet, but it should be very soon).

How to get access token and use it

I am working on creating bot for Microsoft teams in C#. I have a sample code (basic echo bot) that works fine in emulator. I created an app in teams app studio and entered my API end points in Bot section. I download the package and upload it as custom package in teams.
Now, when I add this app and try communicate with Bot, I get unauthorize error in API (using ngrok). I guess what’s going on here is that I don’t have the access token i.e. when someone install it, teams should give you access token, right?
What I don’t know is how teams will give me the access token and where in the process that access token will be used?
So basically, when someone clicks on “Add” button in teams app store, how the access token are passed.
#update
Note:-I have done the app registration as well.
So i did bot channel registration in Azure and added my ngrok end points. I copied the "MicrosoftAppId" and "MicrosoftAppPassword" in appsettings file. It is working fine in emulator as well as "test on web chat" in Azure bot management portal. I also connected it to Teams channel from portal itself. when i navigate to teams from the channel link, my bot is working as expected.
After that i opened app studio and entered all the details. In Bot section, i selected existing bot id and entered my MicrosoftAppId from azure and it worked.
what I still don't understand is, when someone install the app, teams should be sending some information to my end point, right?
Without access to your code it is hard/impossible to determine the cause of your issue.
I suggest instead you take a fresh start by using one of the Teams bot examples that are shared :
57.teams-conversation-bot
if you do require authentication in your bot:
Authentication flow for bots - Teams | Microsoft Docs
46.teams-auth
52.teams-messaging-extensions-search-auth-config
pleanty other teams examples as well in that repo:
50.teams-messaging-extensions-search
51.teams-messaging-extensions-action
53.teams-messaging-extensions-action-preview
54.teams-task-module
55.teams-link-unfurling
56.teams-file-upload
57.teams-conversation-bot
58.teams-start-new-thread-in-channel

QnAmaker sample - The bot's Microsoft App Id or Microsoft App Password is incorrect

I downloaded the QnAmaker sample from here and trying to make it working from bot emulator.
I gave the correct Microsoft App Id and App Password. I even tried with a newly regenerated password. But getting the same error.
Did anyone face this issue? What should I try next to get this resolved?
My app settings
My ngrok settings
I removed ngrok settings from emulator settings.Removed MsApp Id and Ms App Password and then started emulator and the bot is responding. But I need to connect to my QnaMaker on azure and get response based on my knowledge base.
I tried via Web chat from azure portal and it did not responded.
Here is the error message I found in Application insights
Failed to acquire token for client credentials. (AADSTS700016:
Application with identifier 'fXXXXXXXXXXXXXXXXXXXXX2' was not found in
the directory 'botframework.com'. This can happen if the application
has not been installed by the administrator of the tenant or consented
to by any user in the tenant. You may have sent your authentication
request to the wrong tenant. Trace ID:
9XXXXX-46a3-4XX-b8XXX7-c1XXXXX00
"This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant"
How can I ensure that I am sending the request to correct tenant ? Where can I verify this?
Try removing the values for MicrosoftAppId and MicrosoftAppPassword from your appsettings.json file then run the bot and attempt to connect it via the emulator again.
When you connect to a bot in the emulator, AND the appsettings.json (always) or .bot file (only for the development endpoint) has values set for the MicrosoftAppId and MicrosoftAppPassword then you will need to enter these details into the provided fields on the connection screen, see my image below:
If your values in your appsettings.json for MicrosoftAppId and MicrosoftAppPassword are empty i.e. "" then you will not have to enter them at the connection screen and your bot will still work when you are debugging locally, even though your live bot has these set. The exception is when you're using ngrok to debug a production channel using your local code, then you will have to provide the MicrosoftAppId and MicrosoftAppPassword when connecting even though they may not be set locally.
If you want to see the response inside emulator then remove the app id and password from app settings.json file(it has worked for me) and add QnA kb keys in the app settings file. And if you want to test on web chat then add app id and password in the app settings file with QnA kb keys and publish it. Once your bot is published you will be able to test on web chat and change the messaging endpoint to your published url.
By the way if you are using v4 botframework, you will not require ngrok.
I think I might know what caused this - where did you get the Application ID and Application Password from? They need to be from a newly created "Bot" app in the Azure portal. If you don't have the right app+key combo, you can happily communicate with your bot through the emulator, for instance, but it won't be able to connect to other services (e.g. QnAMaker, MS Teams).
In the Azure portal, the "Web App Bot" template will create a Bot app AND a web hosting application in Azure, but there's also an option to create a "Bot Channels Registation" if you're using an existing sample application you've downloaded and are running on your local machine.
This "Bot Channels" option is basically just a placeholder of sorts in Azure, where all the key registration in Azure for the bot is done, but you can host the bot itself anywhere you like (for instance on your local machine, in which case you provide the ngrok address as the endpoint, something like: https://250a1f39.ngrok.io/api/messages (make sure you have the "/api/messages" on there).
On the Settings screen for the bot in the Azure portal, where you capture/update the endpoint, is the "Microsoft App Id" you need. There's also a link to "manage", which should take you to where you can get the password, but the link is currently broken (I think MS is working on fixing it), so to get the password you need a few more steps:
Go to the main Azure home page / main resources listing (small menu icon on top left in Azure)
Go to Azure Active Directory (yes, even in your own personal Azure subscription you would do this - there's still an Azure AD provisioned behind the scenes)
Go to "App Registrations" on the left menu
Go to "Applications from personal account" near the top of the page (NOT on the main top menu, a bit down)
In there you will find your new bot - open it up
Go to "Certificates and secrets"
Click the button to create a "New client secret"
Choose an expiry option and optionally give it a description.
Click Add and once it's added - that's the app password you need

REST API Azure Error: 'Microsoft.Rest.HttpOperationException' Operation returned an invalid status code 'Un Authorized'

I am developing the Embedded Power BI in my application.When I am accessing the reports from my power BI Account. I am unable to get the exception as
REST API Azure Error: 'Microsoft.Rest.HttpOperationException' Operation returned an invalid status code 'Un Authorized'.
I have gave view permissions to my app in Azure portal. I thought there is no wrong with my code. I thought it's related to permissions of my app in Azure portal. I have missed some where else. Please guide me.
for adding permission I have followed below link
https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-register-app/
Here is an update:
I have created new project in https://dev.powerbi.com/apps and choose view dashboard and reports then i am able to get the dashboard and reports but If i add permission to the existing project in https://portal.azure.com/ .I am getting the exception.I don't ,why i am getting exception as Unauthorised with my existing account. Can any one please help me out from this problem.
Thanks in advance.
I ran into the same or a similar problem when setting up an application that did PowerBI embedding. In my scenario I use direct connections in reports I embed. Those reports rely on a PowerBI Data Gateway to get the data. The embedded master account or service principal account needs to be added as an Admnistrator on the PowerBI Data Gateway.
Go to PowerBI.com
Click the gear in the top right corner
Click Manage Gateways
Click on your Data Gateway, it will default to the "Gateway Cluster Settings" tab. Click the Administrators tab and add your embedded master account or service principal as an administrator. Now when you try to view the embedded report the : 'Microsoft.Rest.HttpOperationException' Operation returned an invalid status code 'Un Authorized' will be resolved and you will see the embedded report.

The client application has requested access to resource 'https://outlook.office365.com'. This request has failed

I am trying to test the sample code from office365 API, I could login to my account but after that i would always get this exception
AuthenticationFailedException was caught
AADSTS65005: The client application has requested access to resource 'https://outlook.office365.com'. This request has failed because the client has not specified this resource in its requiredResourceAccess list.
Trace ID: 7a39b0bd-1738-418f-984a-feffae5b5d9b
Correlation ID: 16da7c7f-9f0c-468f-a560-a51b1ac9b3bf
Timestamp: 2014-07-09 07:36:34Z
This is the code that I have been testing this code is generated by the API.
Authenticator authenticator = new Authenticator();
var authInfo = await authenticator.AuthenticateAsync("https://outlook.office365.com");
please help me or point-out what I'm doing wrong, this is my first time developing in office365 please help and thank you.
I just came across your question having run into the same error, so since nobody ever answered I figured I would post the answer I found. This error is related to the permissions set to be requested on the app in the Azure dashboard at https://manage.windowsazure.com.
If you go into your app configuration page and scroll to the bottom, you just need to add the corresponding items under the delegated permissions dropdown.
I got the same error. This is what fixed it for me:
Go to https://manage.windowsazure.com
Go to the corresponding app configuration page.
Scroll to the bottom to "permissions to other applications".
Add "Windows Azure Active Directory" application if it is not already there.
Under delegated permissions check "Enabled Sign-on and read user's profiles"
The consent framework associated with requesting authorization requires that your client application is configured with a static set of permissions to the resources (APIs) that it will call. For example, if your app needs to read the signed in user's mail and read and write to their calendar, you need to select Office 365 Exchange Online as a resource and pick the Read mail and Read and write calendar permissions.
This app configuration can be done in a couple of ways - one way is through your dev environment - like Visual Studio. VS2013 and up have a connector that allows you to register a client app and configure its access to O365 cloud resources. Another way is through the Azure Management Portal (under the AD extension, find your application, click on the configure tab, and configure access through the "permissions to other applications" section.
I recommend that you look through https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks and the following sections which show how register apps through Azure Management Portal and through Visual Studio. Also which sample are you trying here? The sample should contain instructions, including the instructions to set the resource and permission scopes your application needs

Categories