2

我正在尝试嵌入 Azure 时间序列见解。存根应用程序提供了执行此操作的代码。我创建了一个应用注册并向其添加了时间序列洞察 API 权限。我还使用事件源创建了自己的时间序列环境。

现在 JS 库中的身份验证是使用 ADAL 和这段代码来实现的。

 var authContext = new AuthenticationContext({
                clientId: 'xxxxx',
                postLogoutRedirectUri: 'https://insights.timeseries.azure.com',
                cacheLocation: 'localStorage'
            });

通过这段代码,我得到了一个访问令牌。

var promise = new Promise(function (resolve, reject) {
                    authContext.acquireToken(
                        'https://api.timeseries.azure.com/',
                        function (error, token) {
                            console.log(token);

                            if (error || !token) {
                                console.log('Here');
                                // TODO: Handle error obtaining access token
                                document.getElementById('api_response').textContent = error;
                                document.getElementById('loginModal').style.display = "block";
                                document.getElementById('api_response2').textContent = '';
                                return;
                            }

                            //console.log('Token is ' + token);

                            // Use the access token
                            document.getElementById('api_response').textContent = '';
                            document.getElementById('api_response2').textContent = '';
                            document.getElementById('loginModal').style.display = "none";
                            resolve(token);
                        }
                    );
                });

现在,如果我想为所有用户而不是我自己嵌入这个应用程序,我会怎么做?如果我在时间序列环境中将自己从数据访问策略中删除,我会收到 404 表示找不到资源。我可以使用任何其他身份验证方法吗?

我可以简单地将应用程序注册本身与客户端 ID 和密码一起使用吗?

4

1 回答 1

2

目前,您正在遵循在 Time Series Insights 上创建仅限客户端的应用程序的最佳机制。理想情况下,您会将打算使用该应用程序的所有用户添加到该环境的数据访问策略中。如果您有服务器端,则可以使用服务主体发出请求,但这可能会使您的体系结构复杂化。更方便的解决方案是将 AAD 组添加到数据访问策略中,但目前不支持...该功能正在产品积压中进行跟踪。希望这会有所帮助!

于 2019-06-19T00:49:53.850 回答