简体   繁体   English

使用图形 API 从 Azure AD 获取用户配置文件

[英]Get user profile from Azure AD using graph api

I want to develop a timer job (C#), which will run at background without any logged in user, through which i need to fetch user profile (profile image and job title) from Azure AD using a graph api.我想开发一个计时器作业 (C#),它将在没有任何登录用户的情况下在后台运行,我需要通过它使用图形 api 从 Azure AD 获取用户配置文件(配置文件图像和职位)。 I want to achieve this using delegated permissions (User.ReadBasic.All) as i'm not allowed to use application level permissions for User.Read.All.我想使用委托权限 (User.ReadBasic.All) 来实现这一点,因为我不允许对 User.Read.All 使用应用程序级别的权限。 So is there any way i can achieve this.那么有什么办法可以实现这一点。

Yes, but the user will have to sign in to your app at least once to initiate the process.可以,但用户必须至少登录您的应用一次才能启动该过程。

The way you can do this:你可以这样做的方式:

  1. User signs in to your app (this can be a separate Web app for example)用户登录您的应用程序(例如,这可以是一个单独的 Web 应用程序)
  2. You store the refresh token received in a secure manner (per user, each user has their own token)您以安全的方式存储收到的刷新令牌(每个用户,每个用户都有自己的令牌)
  3. Your background process can take this refresh token, and exchange it for an access token + a new refresh token您的后台进程可以使用此刷新令牌,并将其交换为访问令牌 + 新的刷新令牌
  4. Store the new refresh token in the same secure storage将新的刷新令牌存储在同一个安全存储中
  5. Use the access token to do what you need to do使用访问令牌执行您需要执行的操作

This process will work in the background for as long as the refresh tokens work.只要刷新令牌工作,这个过程就会在后台工作。 But they can and do expire.但它们可以而且确实会过期。 You will need to be prepared for this as to make it work again for that user, they will have to repeat step 1 again.您需要为此做好准备,以使其再次为该用户工作,他们将不得不再次重复步骤 1。

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

相关问题 无法使用 Microsoft graph API 从 azure 广告中获取所有用户列表 - Unable to get all user list from the azure ad using Microsoft graph API 使用图形API对Azure AD用户进行身份验证 - Authenticate Azure AD user using graph api 使用Microsoft graph API或Azure AD graph API从用户界面中删除对用户的应用程序访问 - Removing application access to user from User interface by using Microsoft graph API or Azure AD graph api 从 Azure ObjectID 获取 Azure AD 用户配置文件 - Get Azure AD user profile from Azure ObjectID Azure Ad Graph API,获取用户信息和用户设备信息 - Azure Ad Graph API, Get User information and User Device Infromation 使用 Microsoft Graph 如何获取从本地 AD 同步的 Azure AD 用户字段 - Using Microsoft Graph how do i get Azure AD user fields that were synced from On Premise AD 如何使用 Azure AD 获取用户配置文件详细信息 - How to get user profile details using Azure AD 如何使用Azure AD Graph API获取当前用户的登录名/用户名 - How to get Login / username using Azure AD Graph API for current user 如何使用 Azure AD Graph API 中的“备用电子邮件”属性获取用户详细信息 - How to get user details using the 'alternate email' attribute in Azure AD Graph API 使用Graph API在Azure AD B2C上对用户进行身份验证 - Authenticate a user on Azure AD B2C using Graph API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM