MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.47k forks source link

Step 10 not clear #24002

Closed LisandroSu closed 5 years ago

LisandroSu commented 5 years ago

@Eichi87 commented on Fri Feb 01 2019

The whole tutorial is pretty straightforward except for the last step. Where do you pass the token?

I use the authentification header presented during the "Tutorial: Create an Azure Time Series Insights single-page web app", which looks like this:

        // START: AUTHENTICATION RELATED CODE USING ADAL.JS
            // Set up ADAL
            var authContext = new AuthenticationContext({
                clientId: '***',
                postLogoutRedirectUri: 'https://***.azurewebsites.net',
                cacheLocation: 'localStorage'
            });

            if (authContext.isCallback(window.location.hash)) {

                // Handle redirect after token requests
                authContext.handleWindowCallback();
                var err = authContext.getLoginError();
                if (err) {
                    // TODO: Handle errors signing in and getting tokens
                    document.getElementById('api_response').textContent = err;
                    document.getElementById('loginModal').style.display = "block";
                }

            } else {
                var user = authContext.getCachedUser();
                if (user) {
                    document.getElementById('username').textContent = user.userName;

                } else {
                    document.getElementById('username').textContent = 'Not signed in.';
                }
            }

            authContext.getTsiToken = function(){
                document.getElementById('api_response2').textContent = 'Getting tsi token...';

                // Get an access token to the Microsoft TSI API
                var promise = new Promise(function(resolve,reject){
                    authContext.acquireToken(
                    'https://api.timeseries.azure.com/',
                    function (error, token) {

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

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

                return promise;
            }
        // END: AUTHENTICATION RELATED CODE USING ADAL.JS

The Web App has every permission i can think of.

Using Postman I can call a token and the TSI data. Still the Web App doesn't work.


Dokumentdetails

Bearbeiten Sie diesen Abschnitt nicht. Er ist für die Verknüpfung von docs.microsoft.com zum GitHub-Artikel erforderlich.

LisandroSu commented 5 years ago

Hi team,

Please check the issue reported by the user.

Thanks.

Alberto-Vega commented 5 years ago

@LisandroSu Thanks for the feedback! We are currently investigating and will update you shortly.

Alberto-Vega commented 5 years ago

@Eichi87 What is the error you are getting? Also I agree that this document needs to show or link to how the header looks like.

Alberto-Vega commented 5 years ago

@Eichi87 We will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.

dtwaydd commented 5 years ago

Hello, I am trying to follow this example, but also got stomped on how the header looks like. Can this article be revised with the inclusion of the header?

Alberto-Vega commented 5 years ago

@ashannon7 Thoughts on this? Since now we have two customers asking for this, Can you please evaluate the possibility of adding the header or maybe linking to another doc that illustrates this?

darsneymsft commented 5 years ago

Assuming I understand your question, the appropriate header for sending the token is "Authorization" with value "Bearer "

Please let me know if you have additional questions. Thanks!

Alberto-Vega commented 5 years ago

@diogodtway @Eichi87 Can you please confirm?

Alberto-Vega commented 5 years ago

@diogodtway @Eichi87 Were you able to resolve your issue?

Alberto-Vega commented 5 years ago

@matdarMs please consider adding this info to the doc.

KingdomOfEnds commented 5 years ago

@Alberto-Vega-MSFT - This is presently being reviewed in tandem along with several potential Tutorial updates. Thank you for notifying the team!

KingdomOfEnds commented 5 years ago

@Alberto-Vega-MSFT - Pinged you about closing these. I believe this item was addressed and merged. Thanks!

Alberto-Vega commented 5 years ago

@LisandroSu Has your feedback been addressed?

Alberto-Vega commented 5 years ago

Hi @LisandroSu just wanted to touch base with you before closing this issue. Thanks