从Client-managed authentication - Live SDK,我们可以发现您需要传递以下有效负载进行日志记录:
{"authenticationToken":"{Live-SDK-session-authentication-token}"}
然后,我检查了LiveSDK 并尝试通过调用LiveLoginResult.Session.AuthenticationToken 来检索LiveConnectSession.AuthenticationToken,但它返回null。
然后,我检查了 Microsoft 帐户的服务器流身份验证,发现它会使用Live SDK REST API - Signing users in with REST。我试图通过邮递员模拟身份验证请求来验证这个问题。这是我检索访问令牌的测试:
https://login.live.com/oauth20_authorize.srf?client_id={client-id}&redirect_uri={return-url}&response_type=code&scope=wl.basic+wl.offline_access+wl.signin
如您所见,我们无法检索官方文档中提到的authentication_tokenGet an access token and an authentication token。
然后,我尝试使用access_token进行如下日志记录,发现它可以工作。
希望使用 MSAL 客户端流来获得授权访问我已配置为使用 Microsoft 身份验证的 Azure 功能。
对于 MSAL,您会发现它会向以下端点发送请求,{"authenticationToken":"App.TokenRequest.AccessToken"} 和 {"access_token":"App.TokenRequest.AccessToken"} 有效负载都无法成功登录。
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
根据我的测试,由于 Microsoft 的身份验证/授权使用不同的身份验证端点,因此每个端点生成的令牌无法相互应用。
根据我的测试,您可以在 Microsoft Account Developer Center 创建您的应用,并为您的 azure 函数应用添加身份验证信息。对于您的客户,您可以使用 LiveSDK [deprecated] 或 OneDrive SDK for CSharp 进行 MSA 日志记录,并检索 access_token 以使用您的 azure 函数应用进行日志记录。这是我使用 OneDrive SDK 进行日志记录的 UWP 客户端,您可以参考:
var msAuth = new MsaAuthenticationProvider(
"{app-Id}", //application id of your app
"urn:ietf:wg:oauth:2.0:oob", //the redirect url for your native application in your app
new string[] { "wl.signin", "offline_access" });
await msAuth.AuthenticateUserAsync();
MsaAuthenticationProvider可以参考Authentication Adapter for the OneDrive SDK。