我正在开发一个Office外接程序,它目前使用adal来获得一个auth令牌。
由于我想使用Fabric前端,我正在更改它以作出反应,我注意到,军官-js-帮助程序实现了验证器,这些验证器似乎与adal库执行相同的工作。我这个假设是正确的吗?如果是这样的话,如何使用office-js身份验证函数复制adal配置:
var adalConfig = {
instance: 'https://login.microsoftonline.com/',
tenant: 'myprivatesite.onmicrosoft.com',
clientId: 'xxx-xxx-xxx-xxx-xxx',
endpoints: {
'https://my.private.url.endpoint/path': 'https://myprivatesite.onmicrosoft.com/path.to.something',
}而这个象征性的请求:
var authContext = new AuthenticationContext(adalConfig);
authContext.acquireToken('https://myprivatesite.onmicrosoft.com/path.to.something', function (error, token) {
console.log(token)
});更新:我已经让adal.js库在我的react应用程序中工作了。我在init角度提供程序中使用了adalAuthenticationService函数中的一些代码来检索身份验证令牌。
所以问题依然存在。我可以使用office-js-helpers做同样的事情吗?
发布于 2016-11-18 15:49:09
好的,它看起来非常容易。adal配置所需的全部内容是客户机Id和租户。
if (OfficeHelpers.Authenticator.isAuthDialog()) {
return;
}
var authenticator = new OfficeHelpers.Authenticator();
authenticator.endpoints.registerAzureADAuth('xxx-xxx-xxx-xxx-xxx', //clientId
'myprivatesite.onmicrosoft.com' // tenant
);
authenticator.authenticate(OfficeHelpers.DefaultEndpoints.AzureAD)
.then(function (token) {
console.log(token);
.catch(function(error) {
console.log(error);
});https://stackoverflow.com/questions/40674084
复制相似问题