简体   繁体   English

Microsoft Graph和无用户访问

[英]Microsoft Graph and access without a user

I'm trying to upload and download files in my sharepoint online using a background task (daemon) that runs frequently in my ASP.NET Core app. 我正在尝试使用在我的ASP.NET核心应用程序中经常运行的后台任务(守护程序)在线上传和下载我的sharepoint中的文件。 Because it's a background task, no user identity is used. 因为它是后台任务,所以不使用用户身份。 Instead, I tried to follow this document , getting an access token using the https://graph.microsoft.com/.default scope, as well as having my enterprise app on azure having particular permissions already granted by the admin. 相反,我尝试遵循此文档 ,使用https://graph.microsoft.com/.default范围获取访问令牌,以及让我的企业应用程序在azure上具有管理员已授予的特定权限。 管理员同意

I'm able to get an access token using my app's client id and secret. 我可以使用我的应用程序的客户端ID和密码获取访问令牌。 However when I try to request the drives on a particular site on sharepoint, it just stalls, hinting me that it can't reach the path. 但是,当我尝试在sharepoint上的特定站点上请求驱动器时,它只是停顿,暗示我无法到达路径。 I can reach this same path totally fine when I use my user credentials instead. 当我使用我的用户凭证时,我可以完全达到相同的路径。

I think I may be missing a step or some azure administration-related task. 我想我可能会错过一个步骤或一些与天蓝色的管理相关的任务。 Below is the code snippet that shows I can get the access token, but stalls when getting the drives. 下面是代码片段,显示我可以获取访问令牌,但在获取驱动器时会停止。

var client = new ConfidentialClientApplication(id, uri, cred, null, new SessionTokenCache());
var authResult = await client.AcquireTokenForClientAsync(new[] {"https://graph.microsoft.com/.default"});
var token = authResult.AccessToken;  // get token successfully
var graphServiceClient = new GraphServiceClient(new DelegateAuthenticationProvider(async request => {request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token)}));
// stalls below
var drives = await graphServiceClient.Sites[<sharepoint_host>].SiteWithPath(<known_path>).Drives.Request().GetAsync(); 

Using Microsoft Graph SDK within an ASP.NET Core 2 app. 在ASP.NET Core 2应用程序中使用Microsoft Graph SDK。

Edit: Below is an updated screenshot showing application permissions added and consented: 编辑:下面是更新的屏幕截图,显示添加和同意的应用程序权限: 更新截图

Based on your image you have granted delegated permissions to the app. 根据您的图片,您已授予该应用的委派权限。 You need to grant application permissions. 您需要授予应用程序权限。 Delegated permissions only apply when acting on behalf of a user. 委派权限仅在代表用户行事时适用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft graph 无需用户即可访问以获取日历事件 - Microsoft graph get access without a user to get calendar events 没有登录用户的 Microsoft Graph 访问邮箱 - Microsoft Graph Access Mailboxes without Signed-In User 如何在不需要管理员权限的情况下访问Microsoft Graph API中已登录用户的组? - How can I access the signed in user's groups in Microsoft's Graph API without needing admin priviledges? 在 microsoft Graph API 中使用“无需用户获取访问权限”方法时如何获取已登录用户的用户配置文件详细信息 - How to get the user profile details of signed in user when 'Get access without a user' method used in microsoft Graph API 无需用户交互即可获得对 Graph API 的访问权限 - Obtaining access to Graph API without user interaction Microsoft Graph-允许用户访问应用程序/服务主体 - Microsoft Graph - Allow User Access to Application / Service Principal Microsoft Graph API - 如何在没有授权码的情况下获取访问令牌? - Microsoft Graph API - how to get access token without Authorization Code? 如何使用服务用户凭据访问Microsoft Graph的服务 - How to access Microsoft Graph's services with service-user credentials Microsoft Graph API 测试 - 代表用户获取访问权限 - Microsoft Graph API tests - get access on behalf of user 在Microsoft Graph中发送某人作为应用程序的邮件而无需该用户的登录 - Sending a mail for somebody as an application in Microsoft Graph without a login of that user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM