Get SharePoint user detail via Azure Chat bot - c#

I'm developing a chat bot using bot framework form flow to embed in SharePoint online for service ticket creation.
I have used iFrame for to attach it on share point online. Now I need to get the user name & Email ID of the user logged-in the share point site. Since the bot is hosted on Azure and using iFrame the below commands not applicable here
activity.ChannelId;
activity.From.Id;
activity.From.Name;

From what i understand that you want to get user' name and email ID from sharepoint online sites.
I suggest try graph API to get your user'data.
GET https://graph.microsoft.com/v1.0/users?$select=displayName,mail,userPrincipalName
References are here
For anonymous user or get access without user, you can try use the OAuth client credentials grant flow to get an access token.
Register your app.
List itemConfigure permissions for Microsoft Graph on your
app.
Get administrator consent.
Get an access token.
Use the access token to call Microsoft Graph.
For more detailed steps on how to register, here is the link.

Related

Microsoft Graph API Microsoft Login

I'm trying to login into a Skype account from windows application. I'm able to sign-in into the Microsoft account using Graph API(https://graph.microsoft.com/v1.0/me) but in response, I'm unable to get skype name and the other data.
I'm able to login into Microsoft account from windows form application following the steps in below URL.
https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-v2-windows-desktop
I need to know how I can obtain skype name at login using Graph API.Even the Graph API explorer doesn't contain any info regarding skype handle.
https://developer.microsoft.com/en-us/graph/graph-explorer
The Skype api doesn't use the graph api. Instead it has its own endpoint https://webdirX.online.lync.com.
To get a valid access token you have to send a request with the following format:
GET https://login.microsoftonline.com/oauth2/authorize?
response_type=id_token
&client_id=<your-application's-client-id>
&redirect_uri=<reply-uri-for-your-app>
&state=<unique-string-to-track-requests>
&resource=webdirX.online.lync.com
HTTP/1.1
For a introduction on how to use it you should take a look at the Skype for Business authentication using Azure AD article.

How do I authenticate to SharePoint in Bot Framework using logged in user?

I'm working on a bot running on MS Teams.
I'm trying to get logged in user information and use it to authenticate to SharePoint API, but without luck so far.
I'm using the controller from the following example:
https://github.com/stephaneey/transparent-auth-bot/blob/master/transparent-auth-bot/Controllers/MessagesController.cs#L64
But I'm unable to get the token (line 64), it remains null/
The sample you are providing is demonstating the ability to get a Graph API token and reuse it in a Bot.
As you can see here, this token is generated during a specific authentication process: there is a website displaying a webchat, and when you want to access it you have to login. That's where the value of the "GraphAccessToken" is generated and stored in a BotData object, which can be accessed from the code of the bot.
Here if you use MS Teams you never asked the user to login, so there is no magic: the value will be null.
In a few words, if your target channel is Teams, you will not be able to automatically get an user token which you can use to query SharePoint API: you have to go through a manual login process.

How to post client facebook ad by facebook ad api?

I have been working in Facebook ad API. I am able to create abs in sandbox mode as well live mode. Our application is approved. I am getting a strange issue when I try to create ad for my facebook pages its created but when any other user tries to create ad its giving error message like
"{"error":{"message":"Unsupported post request. Object with ID 'act_facebookadaccountid' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"B27E15+gMhB"}}"
We have taken following permission
business_management
manage_pages
Ads Management
Basic Access
My main aim is my customer can connect with our app they can select page for whom they want to run ad and create ad using our app.
Please help me to sort out this
This may have to do with your access level? You need Standard access so any ad account may be used. Otherwise you are limited to the max. 25 ad accounts you specify in the Ads API account configuration tool.
https://developers.facebook.com/docs/marketing-api/access/#limits

Outlook REST API - How to retrieve a User Photo

I would like to get the photos of my users from outlook and store them in my database. I want it to be done automatically by the programm with no user interaction required, because i know their email and password.
I´m trying to use this guide:
https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#UseaclientlibrarytoaccesstheOutlookRESTAPIGetanaccesstoken
I have already registered my website (.NET MVC 5), but I don´t know how to do the authentication and access token part, because half of the links of the guide don´t work and i can´t find any helpful tutorial / code snippets somewhere else.
I´m deeply grateful for any help.
Instead of using Office 365 REST API, we can use the Microsoft Graph.
And since you don't want to the user participate in the authentication, you can using the Client Credentials Grant Flow which permits a web service (a confidential client) to use its own credentials to authenticate when calling another web service, instead of impersonating a user.
Here is the REST API to get the photo for a specific user for your reference:
GET:https://graph.microsoft.com/v1.0/users/user1#yourdomain.onmicrosoft.com/photo/$value
The app requires one of the following scopes to request the photo of user:
User.Read; User.ReadBasic.All; User.Read.All; User.ReadWrite.All; User.Read
And refer to here to register the app using the Microsoft Graph API.

Asp.net and Facebook authentication

I'd like to do the following:
Allow users to register in my asp.net site using their facebook credentials.
Retrieve facebook client information. Like (Name, surname, email address etc). So I can import this information into my application.
Allow users to log into my site using facebook credentials.
I've been searching and have come across these options:
Facebook.net SDK
dotnetoauth
Facebook Connect
Graph API
I'm confused as to which would be the best way to go about this.
I think that this resource offers a good tutorial on how to integrate with Facebook's user infrastructure:
http://devtacular.com/articles/bkonrad/how-to-retrieve-user-data-from-facebook-connect-in-aspnet/
There is also this code example / framework which takes you though much of the process:
http://fbconnectauth.codeplex.com/
And this walkthrough which is a little more up-to-date:
http://area72.ro/general-it/how-to-login-via-facebook-in-asp-net.html
The easiest way to implement your solution would be to use the javascript SDK for this.
You add a Facebook Login button which the user clicks on and authorizes your website giving you access to his information. This basically skips the need for registration for facebook users since the registration is the actual login process.
When the user has authorized your website (thus logged in and registered) you have access to his information which you can use to store in your users database using his faceboook id as a key. You can access the user's information sending an http request to the graph api https://graph.facebook.com/facebook_id which will return a json object with the users information.
Other then the facebook login you will want a standard login, registration form for users without facebook.
http://developers.facebook.com/docs/guides/web/

Categories