MAK
MAK

Reputation: 1288

Embed Azure Time Series Insights using JavaScript library

I'm trying to embed Azure Time Series insights. The stub applications provides the code to do that. I created an app registration and added Time Series insights API permissions to it. I also created my own Time series environment with an event source.

Now the authentication in JS library is achieved using ADAL with this piece of code.

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

And with this piece of code I'm getting an access token.

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);
                        }
                    );
                });

Now, if I want to embed this application for all users and not just me what would I do? If I remove myself from Data Access policies within the time series environment I get a 404 saying resource not found. Can I use any other authentication method?

Can I simply use app registration itself with client Id and secret?

Upvotes: 2

Views: 434

Answers (1)

Matt Darsney
Matt Darsney

Reputation: 36

Presently you are following the best mechanism for creating a client-only application on Time Series Insights. Ideally you would add all users that you intend to use the application to the data access policies for that environment. If you had a server side, you could issue requests using a service principal, but that would likely complicate your architecture. A more convenient solution would be adding an AAD group to the data access policies, but it's not presently supported...That feature is being tracked in the product backlog. Hopefully that helps!

Upvotes: 2

Related Questions