Microsoft Graph:每次启动进程时避免授权
Microsoft Graph: avoid authorization each time I launch a process
我想将 Teams 的 Planner 功能集成到自定义 C++/Qt 应用程序中。我不熟悉编写绑定 C# <-> C++,因此我正在探索使用与 Microsoft Graph 通信的外部进程的可能性。我将使用 C# Graph SDK.
构建此流程
问题:是否可以在每次启动进程时都避免验证?因为我要多次生成这个过程(即每次我需要访问图形信息)我想避免每次都进行身份验证。
我已经尝试使用 Microsoft authentication extensions for .NET,虽然示例应用程序似乎工作正常,但我不知道如何将它与 GraphServiceClient
class 连接。
// This is how the example set up the cache
// See: https://github.com/AzureAD/microsoft-authentication-extensions-for-dotnet/blob/master/sample/ManualTestApp/Program.cs#L32
var pca =
CreatePublicClient("https://login.microsoftonline.com/organizations");
var cacheHelper =
CreateCacheHelperAsync().Result;
cacheHelper.RegisterCache(pca.UserTokenCache);
// This is how the GraphServiceClient is created in the tutorial
// See: https://docs.microsoft.com/en-us/graph/tutorials/dotnet-core?tutorial-step=3
tokenCredential = new DeviceCodeCredential(callBack, clientId);
graphClient = new GraphServiceClient(tokenCredential, scopes);
我正在使用 DeviceCode 身份验证流程,因为我知道这对桌面应用程序来说是正确的做法,但我可以更改方法。
最终应用程序将在 Linux 上部署。
我在这个 repo 中找到了我需要的东西:https://github.com/Azure-Samples/ms-identity-dotnet-desktop-tutorial/tree/master/2-TokenCache
我需要做一些调整来为 .NET Core 编译它,但代码运行完美。
我想将 Teams 的 Planner 功能集成到自定义 C++/Qt 应用程序中。我不熟悉编写绑定 C# <-> C++,因此我正在探索使用与 Microsoft Graph 通信的外部进程的可能性。我将使用 C# Graph SDK.
构建此流程问题:是否可以在每次启动进程时都避免验证?因为我要多次生成这个过程(即每次我需要访问图形信息)我想避免每次都进行身份验证。
我已经尝试使用 Microsoft authentication extensions for .NET,虽然示例应用程序似乎工作正常,但我不知道如何将它与 GraphServiceClient
class 连接。
// This is how the example set up the cache
// See: https://github.com/AzureAD/microsoft-authentication-extensions-for-dotnet/blob/master/sample/ManualTestApp/Program.cs#L32
var pca =
CreatePublicClient("https://login.microsoftonline.com/organizations");
var cacheHelper =
CreateCacheHelperAsync().Result;
cacheHelper.RegisterCache(pca.UserTokenCache);
// This is how the GraphServiceClient is created in the tutorial
// See: https://docs.microsoft.com/en-us/graph/tutorials/dotnet-core?tutorial-step=3
tokenCredential = new DeviceCodeCredential(callBack, clientId);
graphClient = new GraphServiceClient(tokenCredential, scopes);
我正在使用 DeviceCode 身份验证流程,因为我知道这对桌面应用程序来说是正确的做法,但我可以更改方法。
最终应用程序将在 Linux 上部署。
我在这个 repo 中找到了我需要的东西:https://github.com/Azure-Samples/ms-identity-dotnet-desktop-tutorial/tree/master/2-TokenCache
我需要做一些调整来为 .NET Core 编译它,但代码运行完美。