我正在尝试将 Skype for Business 集成到我当前的 AngularJS Web 应用程序中。我已按照 https://msdn.microsoft.com/en-us/library/office/mt622687(v=office.16).aspx 上的步骤操作,但无法登录。
我相信我的应用程序已在 Azure AD 上正确注册,因为我之前已将 Outlook (O365) 集成到具有相同要求的应用程序中。
因此,我使用以下初始化通过adalAuthenticationServiceProvider使用Office 365 Online 对用户进行身份验证(下面的示例屏蔽了租户和 clientId 的部分):
var endpoints = {
'https://outlook.office365.com': 'https://outlook.office365.com',
'https://webdir.online.lync.com': 'https://webdir.online.lync.com'
};
// Initialize the ADAL provider with your tenant name and clientID (found in the Azure Management Portal).
adalAuthenticationServiceProvider.init(
{
tenant: 'xxxxxxxxxxxx1.onmicrosoft.com',
clientId: '8720xxxx-xxxx-xxxx-xxxx-xxxxe2a3a20c',
redirectUri: 'http://localhost/defaultDashboard',
postLogoutRedirectUri: 'http://localhost/defaultDashboard',
cacheLocation: 'localStorage',
anonymousEndpoints: ["/"],
endpoints: endpoints
},
$httpProvider
);
然后,我尝试登录到 Skype for Business Online,然后尝试使用从 Azure AD 接收到的访问令牌登录用户,该访问令牌存储在我们的adalAuthenticationService 中:
var config = {
apiKey: 'a42fcebd-5b43-4b89-a065-74450fb91255', // SDK
apiKeyCC: '9c967f6b-a846-4df2-b43d-5167e47d81e1' // SDK+UI
};
Skype.initialize({ apiKey: config.apiKey }, function (api) {
var app = new api.application;
app.signInManager.state.changed(function (state) {
console.log("Login State: " + state);
});
app.signInManager.signIn({
"client_id": "8720xxxx-xxxx-xxxx-xxxx-xxxxe2a3a20c", //GUID obtained from Azure app registration.
"origins": ["https://webdir.online.lync.com/autodiscover/autodiscoverservice.svc/root"],
"cors": true,
"redirect_uri": 'http://localhost/defaultDashboard', // Can be any location in the current site. (Any valid Url)
"version": 'xxxxx/1.0.0.0'
});
var resource = adalAuthenticationService.getResourceForEndpoint('localhost');
var tokenStored = adalAuthenticationService.getCachedToken(resource);
if (tokenStored) {
var Bearercwt = 'Bearer cwt=';
var Bearer = 'Bearer ';
var cwt = 'cwt';
if (tokenStored.indexOf(cwt) == -1) {
tokenStored = Bearercwt + tokenStored;
}
if (tokenStored.indexOf(Bearer) == -1) {
tokenStored = Bearer + tokenStored;
}
var options = {
auth: function (req, send) {
req.headers['Authorization'] = tokenStored.trim();
return send(req);
},
domain: 'localhost'
};
app.signInManager.signIn(options).then(
function () {
console.log('Signed in as ' + app.personsAndGroupsManager.mePerson.name());
},
function(err) {
console.log('Sign in failed: '+err);
});
}
}, function (err) {
console.log("cannot load the sdk package", err.toString());
});
我首先要指出,我不清楚开发文档为什么建议两个单独的signInManager.signIn调用。然而,我真正的问题是,第一个登录调用(使用 clientId)触发了一个 GET 调用,该调用由于“无效凭据”而被拒绝(见下文)。
webdirca1.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user:401
之后,这个相同的调用每 3 秒循环触发一次,这次返回“服务不允许来自该来源的跨域请求”错误(见下文)。
webdirca1.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user:403
如果我注释掉第一个登录调用并尝试仅使用从 Azure AD 身份验证收到的访问令牌登录,我将面临来自 https://lyncdiscoverinternal.localhost/xframe 和 https 的两个 net::ERR_SSL_PROTOCOL_ERROR lyncdiscover 错误:/ /lyncdiscover.localhost/xframe (见下文;PS 如果我将域从 localhost 更改为我的 Azure AD 租户,我会收到相同的错误)。
我是否缺少为 Skype for Business Online 开发 Web SDK 应用程序的任何先决条件?任何帮助将不胜感激。