Bot Builder : How to create a bot using OAuth 2 implicit grant flow method in sharepoint - azure

I'm trying to create a bot in a sharepoint site. To do that i need to retrieve the user info using implicit flow authentification method, however i haven't found any example using .NET and all the examples are in Node.js.
Can someone show me how to do that please ?

There are a number of .net examples online:
https://stephaneeyskens.wordpress.com/2017/01/04/microsoft-bot-framework-transparent-authentication-with-the-webchat-control/
https://github.com/Ellerbach/SharePointBot
https://www.rickvanrousselt.com/contextual-authentication-webchat-control/
https://www.linkedin.com/pulse/chat-bot-luis-sharepoint-part-one-akshay-deshmukh/
However, they are a little dated. Just this week, Microsoft released a new integrated OAuth feature for bots.
One of the Service Providers is Sharepoint:

Related

Microsoft teams chatbot searching in sharepoint library

I have developed a basic Teams chatbot using the Hello World Tutorial from Microsoft (with Node.js). What I would like to make this bot able to search through the Sharepoint documents library. Users could ask questions like "the contract for product B" to the bot in teams and the bot could reply with the doc url or, better, the doc itself. So :
Is it possible ?
If yes would you know a tutorial that could help me ?
Thanks
Yes, this is possible. You need to be aware that a bot is basically just a web service with a special REST endpoint, so it can do anything any other web service can do, which includes for example calling to SharePoint. The important thing for you to be aware of is that the bot / web service has no access rights by itself into SharePoint, so you need to think about authentication to the SharePoint library. In short:
You should use Microsoft Graph to connect to SharePoint, something like this: https://learn.microsoft.com/en-us/graph/api/resources/onedrive?view=graph-rest-1.0 or more specifically this: https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http
If you look at the Permissions section in the above link, notice that your service (i.e. bot) needs to have either 'Application' permissions, which means a standard permission applied to the bot itself, and granted by the tenant admin, to retrieve any files, or 'delegated' which means it can only fetch items the user has access to, and the bot operates on the user's behalf. The 2nd option requires you to implement SSO in your bot, to get the user's access token, exchange it for a Graph token (something called an "OBO" or "On Behalf of" exchange), and then calling to SharePoint.
I've tried to keep the answer focused on your question. If you want more details, especially on the 2nd part which is more detailed and might not be familiar to you, let me know, but it should be a separate question here on this site in that case.

How to configure Microsoft Healthbot?

I'm working on a project to integrate a healthcare assistant bot on a mobile application with React Native
I saw that there was a bot from Microsoft for health and therefore adapted for my project, so I would like to use it
So I created an account on Azure and created my bot, however I can't and don't really understand how to configure it to use it and integrate it into my project.
On the Microsoft documentation I see that we have to configure the DirectLine to use a Microsoft bot but I can't activate this on mine, I don't have the option, moreover it's considered as a Saas and not as a bot application on azure, so I don't have the same options and I don't really understand exactly why (I tried with the cli without success, so I think we can't configure DirectLine on a HealthBot)
Then I found this https://github.com/Microsoft/HealthBotContainerSample/tree/live_agent_handoff
The README.md indicates that we must deploy the bot, which I did, I also set the variables to add. But then I don't know exactly what to do to integrate that into my application. I also wonder how to take into account the creation of scenarios on azure.
If someone could enlighten me on how I should proceed to integrate this, I would be grateful. I also saw that there was a module (react-gifted-chat) for creating chat bot, but in the tutorials I meet, everyone uses the DirectLine, so I wonder if it's possible or do I have to go through a Web View?
Thank you in advance!
Microsoft has a doc, titled “Embed a health bot instance in your application”, that should answer your questions. You can find the doc here.
It includes:
GitHub samples
Code examples
Steps for securing communication
Information on how to setup Direct Line
A link and steps for setting up WebChat as an iframe or web page element (in a div, for example)
Hope of help!

Project Online CSOM without using SharePointOnlineCredentials

We have a console application running every night which updates some project plans with CSOM. This uses the SharePointOnlineCredentials for authentication.
But the IT departments wants to change the flag of LegacyAuthProtocolsEnabled of the tenant to false. This has as consequence that SharePointOnlineCredentials can no longer be used as you can read here.
A suggested approach in the link above was to use a ClientId and ClientSecret. I've tested this with the PnP Core AutheticationManager function GetAppOnlyAuthenticatedContext. This works for a ClientContext object for SharePoint Online but it does not work after modifying this function to return a ProjectContext object. A ProjectServerError "GeneralNotLicensed" is thrown because the SharePoint Principal does not have a Project Online license (see here).
My third attempt was to use the Office365ClaimsHelper class found here. This contacts https://login.microsoftonline.com/extSTS.srf for a SAML token by providing the username and password. Now this approach works for a demo environment, but not for the production environment. I suspect because this has a Multi-Factor authentication.
To put things short: does anyone have an idea on how to get a ProjectContext object without using SharePointOnlineCredentials and without showing a pop-up to log in a user on a Multi-Factor authentication environment?
Managed to find a working solution thanks to following PowerShell script: https://blogs.technet.microsoft.com/sharepointdevelopersupport/2018/02/07/sharepoint-online-active-authentication/
Translated this to C# code and calls to Project Online CSOM work!

SharePoint Framework AadHttpClient - operation is part of experimental feature

I'm trying to use the AadHttpClient library that comes with SPFx to connect to a custom API secured by an app registration in Azure AD.
However when I run the web part in the workbench, SharePoint Online (in the tenant _layouts) I get an error in the console saying that the feature is experimental.
Error: The requested operation is part of an experimental feature that is not supported in the current environment.
As far as I can make out from this article, it should be in general release.
When connecting to Azure AD-secured APIs, we recommend that you use the MSGraphClient and AadHttpClient classes, which are now generally available. For more information about the recommended models, see Connect to Azure AD-secured APIs in SharePoint Framework solutions and Use the MSGraphClient to connect to Microsoft Graph.
When I go to the API management page in SP Admin site I get a popup stating
***Access to Azure Active Directory resources using the SharePoint Framework will be available soon.
So I'm a bit confused.
I also get an error on the API management page saying..
A null value was found with the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.
I also get the same error when I try in PowerShell running
Get-SPOTenantServicePrincipalPermissionRequests
I'm not 100% sure I understand the relevance of the API management page - does an admin need to approve just once for the web part then all users are good to go?
I was having the same issue. The github thread can be found here. What fixed it for me was adding the account I was using as a site collection admin.
Connect-SPOService
Set-SPOUser -Site https://TENANT-admin.sharepoint.com -IsSiteCollectionAdmin $True -LoginName yourLoginName

Is Form Based Authentication possible in trial version of SharePoint online

I think, Microsoft uses claim based authentication for trial version of SharePoint online by default but it might be possible to use Form Based Authentication in Dedicated O365.
I need to test or write application to authenticate users for SharePoint online which may have claim based or form based authentication.
so Is there any way to create SharePoint online site that uses form based authentication? Or Is there any SharePoint online test site for this?
I have one more question:
In SharePoint online, I have invited one external(hotmail) user.
I wanted to know details steps on how the external user is authenticated?
Thanks

Resources