aspnet-connect-rest-sample | NET MVC sample shows how to connect to Microsoft Graph | Azure library
kandi X-RAY | aspnet-connect-rest-sample Summary
kandi X-RAY | aspnet-connect-rest-sample Summary
This sample shows how to connect an ASP.NET 4.6 MVC web app to a Microsoft work or school (Azure Active Directory) or personal (Microsoft) account using the Microsoft Graph API to retrieve a user's profile picture, upload the picture to OneDrive, and send an email that contains the photo as an attachment and the sharing link in its text. It uses REST calls to interact with the Microsoft Graph API. In addition, the sample uses the Microsoft Authentication Library (MSAL) for authentication. The MSAL SDK provides features for working with the Azure AD v2.0 endpoint, which enables developers to write a single code flow that handles authentication for both work or school (Azure Active Directory) and personal (Microsoft) accounts.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aspnet-connect-rest-sample
aspnet-connect-rest-sample Key Features
aspnet-connect-rest-sample Examples and Code Snippets
Community Discussions
Trending Discussions on aspnet-connect-rest-sample
QUESTION
All I am trying to do is to fetch emails for a userID which is accessible to other users without having them logging into their Microsoft accounts. I have looked at numerous SO posts (this), code samples (this, this) and looked into the specs of OpenID and other docs (this), but still not able to figure it out.
I have registered app in azure portal and granted required permissions. Using the sample app I am able to fetch user list, but not the email list. I compared the request headers for both user query and email query. Both look the same. Can someone please tell me what I am doing wrong?
Code is given below:
Startup.Auth.cs
...ANSWER
Answered 2018-Nov-02 at 21:25You're using Client_Credentials
to authenticate the app and using the /me
path in your REST call. These two do not work together.
Behind the scenes /me
is translated into the currently authenticated user (i.e. /users/user@domain
. Since you don't have a user authenticated, it simply isn't possible for the Graph to translate your request into an actionable call.
You need to explicitly reference the user using either their id
or their userPrincipalName
:
QUESTION
I've successfully written an API that can access a downstream API (using v1 ADAL.NET), so, I have some codes for that.. (the clients were based on AutoRest)
Furthermore, I've successfully gotten a sample Microsoft Graph web app running (but, it's coded for v2 and MSAL)
Does anyone have an example of an API accessing a downstream API (i.e. Microsoft Graph). While I can successfully get my access token, when I go to make the call I only get a Microsoft.Graph.ServiceException
:
ANSWER
Answered 2018-Aug-09 at 14:23OK, the key things I've learned about interacting with Microsoft Graph API:
- Yes, you CAN use the new client api NuGet from here with v1 and v2 app registrations
- An example of the
GraphServiceClient
client in use is found at this QuickStart but it goes against v2 using MSAL - Borrow code from this sample project to do v1 (ADAL.NET) interactions with traditional app registrations in the portal
- Where I went wrong: somewhere along the way, I thought the resourceUri I was supposed to use was
https://graph.windows.net
, but it's really just:https://graph.microsoft.com
QUESTION
I am using MS Graph example to deal with groups. I have modified my code from the mentioned link. I am able to all my operations with admin account but not with normal user. I am using permission scopes as User.Read Mail.Send Files.ReadWrite Group.ReadWrite.All
. Once run the app with admin account and grant the permissions those permissions are not reflecting to normal user. When normal user signin it is again asking for admin consent. What wrong I am doing?
ANSWER
Answered 2018-Mar-15 at 18:20There are two types of "consent" in Azure AD land:
User Consent: Asks a User to consent to the app doing x,y,z on their behalf.
Admin Consent: Asks an Admin to consent to "Non-Admin" users executing User Consent.
In other words, "Admin Consent" is not the same as an Admin executing "User Consent". All that does is consent to your application operation on behalf of that Admin, it doesn't affect any other users.
What you need here is to execute an Admin Consent operation. This uses a slightly different URL then you currently use to sign in to your app. I'd suggest taking a look at these articles that cover how this works (discloser: I am the author):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aspnet-connect-rest-sample
Download or clone the Microsoft Graph Connect Sample for ASP.NET 4.6.
Open the sample solution in Visual Studio.
In the Web.config file in the root directory, replace the ida:AppId and ida:AppSecret placeholder values with the application ID and password that you copied during app registration.
Press F5 to build and run the sample. This will restore NuGet package dependencies and open the app. If you see any errors while installing packages, make sure the local path where you placed the solution is not too long/deep. Moving the solution closer to the root of your drive resolves this issue.
Sign in with your personal or work or school account and grant the requested permissions.
Choose the Get email address button. When the operation completes, the email address of the signed-in user is displayed on the page.
Optionally edit the recipient list and email subject, and then choose the Send email button. When the mail is sent, a Success message is displayed below the button.
Next steps: Check out the Microsoft Graph Snippets Sample for ASP.NET 4.6 to see examples of common Microsoft Graph operations.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page