标签: microsoft-graph

使用API​​在OneDrive上创建文件夹

我正在尝试通过API在OneDrive上创建新文件夹,但出现异常

致命错误:错误消息“ League \ OAuth2 \ Client \ Provider \ Exception \ IdentityProviderException”未捕获,必须提供以下方面之一才能创建项目:Bundle,File,Folder,RemoteItem

这是与$a = ["name" => "Folder"];

如果我将其更改为:

$a = ["name" => "Folder", "folder" => array()];
$this->provider->post('https://graph.microsoft.com/v1.0/me/drive/root/children',$a,$_SESSION['access_token']);
Run Code Online (Sandbox Code Playgroud)

然后我得到

有效负载中的属性文件夹的值与架构不匹配

示例页面中,我假设该folder值应为空数组。

azure onedrive microsoft-graph

2
推荐指数
1
解决办法
788
查看次数

Microsoft.Graph获取组的所有用户

我正在使用Microsoft.Graph,我想返回特定组中所有用户的列表.我找不到任何关于此的可消化信息.

我尝试过使用,.Request().Expand(x => x.Members)但这只会返回20个用户.它们没有被分页(见这里).

我可以很好地提取组列表,但是如何根据用户所在的组来过滤用户?这是我到目前为止所得到的......

public async Task Do()
{
    var graphClient = new GraphServiceClient(_authProvider);
    var groups = await graphClient.Groups.Request().GetAsync();

    do
    {
        foreach (var group in groups)
        {
            Console.WriteLine($"{group.Id}, {group.DisplayName}");
            Console.WriteLine("------");

            var filter = $""; // What goes here?
            var users = await graphClient.Users.Request().Filter(filter).GetAsync();

            do
            {
                foreach (var user in users)
                {
                    Console.WriteLine($"{user.Id}, {user.GivenName} {user.Surname}, {user.MemberOf}");
                }
            }
            while (users.NextPageRequest != null && (users = await users.NextPageRequest.GetAsync()).Count > 0);

            Console.WriteLine();
        }
    }
    while (groups.NextPageRequest != null …
Run Code Online (Sandbox Code Playgroud)

c# microsoft-graph

2
推荐指数
1
解决办法
3316
查看次数

使用所有者在Microsoft Graph API中创建一个组

我有一个Office 365组,我想通过Microsoft Graph API添加.基于API文档,我相信我需要

POST https://graph.microsoft.com/v1.0/groups
Content-type: application/json
Content-length: 244
Run Code Online (Sandbox Code Playgroud)
{
  "description": "Self help community for library",
  "displayName": "Library Assist",
  "groupTypes": [
    "Unified"
  ],
  "mailEnabled": true,
  "mailNickname": "library",
  "securityEnabled": false
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试添加时

"owner": [{ "@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"}]
Run Code Online (Sandbox Code Playgroud)

我收到一个错误(该ID实际上是办公室中存在的ID,所以我不想把它放在这里).

如果我首先运行创建组然后添加所有者但不在一起,它们可以工作.为什么?

想尽可能让我这么容易.我将邮递员放在标签中只是因为那是我目前正在使用的工具

microsoft-graph

2
推荐指数
2
解决办法
1876
查看次数

Microsoft Graph API - 限制

在请求开始受到限制之前,应用程序可以向Microsoft Graph API发出特定数量的请求/分钟(特定于租户)吗?

microsoft-graph

2
推荐指数
1
解决办法
1960
查看次数

我应该在后端还是前端进行第三方API调用?

我有一个API,该API需要来自Microsft Graph API的一些数据。我当时正在考虑在我的API中实现一个端点,以刷新令牌并使用该令牌从前端进行调用。我不知道这是最佳还是安全,因此我提出了问题。

编辑1:为了更好地了解我所拥有的,这就是我目前的逻辑。请告诉我这是否正确。

用户请求我的API的授权终结点,该终结点具有Azure的秘密密钥,然后将用户重定向到Microsft oAuth登录页面。登录oAuth后,Microsoft会将用户重定向到我的API,在该API中将JWT令牌保存在用户的Cookie中,以便用户可以随时刷新令牌。

为了刷新令牌,用户只需简单地调用myapi.com/auth/microsoft/token,就拥有密钥,然后刷新。

node.js azure-active-directory microsoft-graph

2
推荐指数
1
解决办法
1177
查看次数

如何使用Microsoft Graph授权Outlook.com?

把我的生活变成碎片,这是我的最后一招.

说真的,我无法在任何地方找到这些信息!我认为Graph支持Outlook.com.我看到这个引用Outlook Api和Graph Api的问题,但是如何为此授权Outlook.com帐户呢?

我正在向用户发送https://login.microsoftonline.com/common/oauth2/authorize参数:

response_type = code
client_id = <my client id>
redirect_uri = <my redirect_uri>
state = <csrf>
resource = https://outlook.office.com/
Run Code Online (Sandbox Code Playgroud)

登录.它@outlook.com会将它们带到Office 365登录,当您键入时,它会尝试重定向您,只返回365登录页面并全部执行.

我可以很好地授权Office 365,但不能Outlook.com.如果需要,我可以提供更多信息,我只是觉得我遇到了错误的端点或其他什么.

outlook-web-app outlook.com office365api microsoft-graph

1
推荐指数
1
解决办法
443
查看次数

使用"代表流的Web API"创建Microsoft Graph webhook时访问令牌验证失败

我想要做的是使用Microsoft 本文中描述的"Web API代表流"方案来创建Web挂钩.

所以我从Microsoft github示例开始,确保我可以通过Graph API成功获取用户配置文件.

然后我修改了获取用户配置文件的代码来创建Web挂钩,因此代码如下所示:

// Authentication and get the access token on behalf of a WPF desktop app.
// This part is unmodified from the sample project except for readability.

const string authority = "https://login.microsoftonline.com/mycompany.com";
const string resource = "https://graph.windows.net";
const string clientId = "my_client_id";
const string clientSecret = "my_client_secret";
const string assertionType = "urn:ietf:params:oauth:grant-type:jwt-bearer";

var user = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
var authenticationContext = new AuthenticationContext(authority,new DbTokenCache(user));
var assertion = ((BootstrapContext) ClaimsPrincipal.Current.Identities.First().BootstrapContext).Token;
var userName = ClaimsPrincipal.Current.FindFirst(ClaimTypes.Upn) …
Run Code Online (Sandbox Code Playgroud)

azure webhooks azure-active-directory azure-ad-graph-api microsoft-graph

1
推荐指数
1
解决办法
3971
查看次数

是否需要通过https://apps.dev.microsoft.com注册新的应用程序?

我是否必须通过https://apps.dev.microsoft.com向我的MS帐户注册一个新应用程序

- 要么 -

我可以在Azure Active Directory中添加一个新的应用程序吗?

我想使用OAuth2隐式流程来使用Microsoft Graph单点登录.我通过Active Directory中的Azure门户创建了一个新应用程序,在清单中启用了隐式流程 "oauth2AllowImplicitFlow": true,启用了多租户环境.目标是为个人和组织帐户启用单点登录,基本上每个人都拥有MS帐户.要验证和请求新令牌,我使用的是公共端点:

public const string AuthorizationEndPoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize";

public const string TokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token";
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误消息:

https://login.live.com/err.srf?lc=1033#error=unauthorized_client&error_description=The+client+does+not+exist.+If+you+are+the+application+developer%2c+configure+a +新+应用+通过在+ HTTPS +的+应用+管理+网站+://apps.dev.microsoft.com/.&state=ABC...EFG

在Azure门户中,我确实看到失败的登录以及以下消息.

FAILURE REASON The application named X was not found in the tenant named Y. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the …
Run Code Online (Sandbox Code Playgroud)

azure azure-active-directory microsoft-graph

1
推荐指数
1
解决办法
2366
查看次数

使用Microsoft Graph SDK 1.4 NuGet的增量查询

我正在尝试使用.NET客户端库(来自https://www.nuget.org/packages/Microsoft.Graph的 1.4版)设置一个增量查询示例。进行初始调用很顺利:

var page = await _graphClient.Users.Delta().Request().GetAsync();

while (page.NextPageRequest != null)
{
  page = await page.NextPageRequest.GetAsync();
}
Run Code Online (Sandbox Code Playgroud)

一段时间后获得deltaLink仍然很明显:

string deltaLink = (string)page.AdditionalData["@odata.deltaLink"];
Run Code Online (Sandbox Code Playgroud)

但是,以后使用此deltaLink的正确方法是什么?我还没有找到明显的方法/构建器,该方法/构建器将允许我以后使用URL继续运行(我当前的解决方案是使用https: //“使用.Net Microsoft Graph客户端库发送HTTP请求”部分中的代码: //github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/overview.md并将其投放到UserDeltaCollectionResponse-那时我可以再次使用普通的API)。

microsoft-graph

1
推荐指数
2
解决办法
625
查看次数

如何通过Azure AD检查用户是否在AD组中?

设置规格

  • .NET 4.5.1 MVC项目
  • 项目包含.aspx文件(旧版)
  • 当前,用户Azure AD通过Cookie进行身份验证。
  • Azure门户(通过应用程序注册)配置为“隐式授予-ID令牌”和“仅此组织目录中的帐户”
  • 本地AD组被上推到Azure AD。

Startup.cs配置

// COOKIES: Tells it to use cookies for authentication.
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
    CookieManager = new SystemWebCookieManager()
});

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
{
    ClientId = ClientID,
    Authority = Authority,
    PostLogoutRedirectUri = PostLogoutRedirectUri,
    Notifications = new OpenIdConnectAuthenticationNotifications()
    {
        AuthenticationFailed = PrincipalService.OnAzureAuthenticationFailure,
        AuthorizationCodeReceived = (AuthorizationCodeReceivedNotification notification) =>
        {
            var username = notification.AuthenticationTicket.Identity.Name.Split('#').LastOrDefault();
            var emailAddress = notification.AuthenticationTicket.Identity.Claims.FirstOrDefault(x => x.Type.Contains("emailaddress"))?.Value;
            Logger.Log(Level.Auth, $"Azure login success! Username: '{username}' Email: '{emailAddress}'.");
            return Task.FromResult(0);
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

在进行此设置后,如何检查当前登录的用户是否在特定的AD组中? …

azure-active-directory microsoft-graph

1
推荐指数
1
解决办法
587
查看次数