none
Unable to access API after oauth sign in RRS feed

  • Question

  • I'm having issues trying to access the web SDK after oauth authentication. I believe I have all the Azure Portal registration stuff squared away. I have the site successfully redirecting to the oauth sign in. After signing in, it will redirect successfully back to the app but I am unable to use the Skype Web API to get any information like Status. 

    The console is showing errors where 'Set-Cookie' is being ignored. Is there something I'm doing wrong?

    My javascript code is below:

    var Application;
    var skypeWebApp;
    
    $(document).ready(function () {
    
        var config = {
            apiKey: 'a42fcebd-5b43-4b89-a065-74450fb91255', // SDK
            apiKeyCC: '9c967f6b-a846-4df2-b43d-5167e47d81e1' // SDK+UI
            , clientID: 'xxxxxxxxx'
        };
    
        var hasToken = /^#access_token=/.test(location.hash);
        var hasError = /^#error=/.test(location.hash);
    
        var client_id = config.clientID;
    
        // redirect to Org ID if there is no token in the URL
        if (!hasToken && !hasError) {
            location.assign('https://login.microsoftonline.com/common/oauth2/authorize?response_type=token' +
                '&client_id=' + client_id +
                '&redirect_uri=' + location.href +
                '&resource=https://webdir.online.lync.com');
        }
    
        // show the UI if the user has signed in
        if (hasToken) {
            Skype.initialize({ apiKey: config.apiKey }, function (api) {
                var app = new api.application();
    
                app.signInManager.state.changed(function (state) {
                    console.log("Login State: " + state);
                });
                var options = {
                    "client_id": config.clientID,  //GUID obtained from Azure app registration.
                    "origins": ["https://webdir.online.lync.com/autodiscover/autodiscoverservice.svc/root"],
                    "cors": true,
                   
                    "redirect_uri": 'xxxx/xxxx.html', // Can be any location in the current site. (Any valid Url)
                    "version": 'xxxxxx/1.0.0.0'
                };
    
                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());
            });
        }
    
        if (hasError) {
            console.log(location.hash);
        }
    });
    
    

    Thank you

    Friday, May 17, 2019 7:40 PM