examples/browser/browser-app.js
function init() {
        // initialize the SDK with the domain where Just is running and the
        // OAuth 2.0 implicit flow parameters
        sdk = new window.JustSDK({
            domain: 'JUSTDOMAIN',
            oauth2: {
                // adapt this to point to the correct domain and path
                redirect_uri: 'https://YOURDOMAIN/browser-app-authorized.html',
                // the client ID of this app. Must have been registered at the
                // Just installation configured under 'domain' above.
                client_id: 'YOUR_CLIENT_ID',
                flow: 'implicit'
            }
        });

        var loginBtn = document.querySelector('#login');
        var logoutBtn = document.querySelector('#logout');

        loginBtn.addEventListener('click', function() {
            printInfo();
        });
        logoutBtn.addEventListener('click', function() {
            window.localStorage.removeItem('just:accessToken:' + sdk.config.domain);
            window.location.reload();
        });
        getToken(false).then(function() {
            logoutBtn.style.display = '';
            loginBtn.style.display = 'none';
            printInfo();
        }, function() {
            loginBtn.style.display = '';
            logoutBtn.style.display = 'none';
        });
    }
function init() {
        // initialize the SDK with the domain where Just is running and the
        // OAuth 2.0 implicit flow parameters
        sdk = new window.JustSDK({
            domain: 'JUSTDOMAIN',
            oauth2: {
                // adapt this to point to the correct domain and path
                redirect_uri: 'https://YOURDOMAIN/browser-app-authorized.html',
                // the client ID of this app. Must have been registered at the
                // Just installation configured under 'domain' above.
                client_id: 'YOUR_CLIENT_ID',
                flow: 'implicit'
            }
        });

        var loginBtn = document.querySelector('#login');
        var logoutBtn = document.querySelector('#logout');

        loginBtn.addEventListener('click', function() {
            printInfo();
        });
        logoutBtn.addEventListener('click', function() {
            window.localStorage.removeItem('just:accessToken:' + sdk.config.domain);
            window.location.reload();
        });
        getToken(false).then(function() {
            logoutBtn.style.display = '';
            loginBtn.style.display = 'none';
            printInfo();
        }, function() {
            loginBtn.style.display = '';
            logoutBtn.style.display = 'none';
        });
    }
function init ( ) { // initialize the SDK with the domain where Just is running and the // OAuth 2.0 implicit flow parameters sdk = new window . JustSDK ( { domain : 'JUSTDOMAIN' , oauth2 : { // adapt this to point to the correct domain and path redirect_uri : 'https://YOURDOMAIN/browser-app-authorized.html' , // the client ID of this app. Must have been registered at the // Just installation configured under 'domain' above. client_id : 'YOUR_CLIENT_ID' , flow : 'implicit' } } ) ; var loginBtn = document . querySelector ( '#login' ) ; var logoutBtn = document . querySelector ( '#logout' ) ; loginBtn . addEventListener ( 'click' , function ( ) { printInfo ( ) ; } ) ; logoutBtn . addEventListener ( 'click' , function ( ) { window . localStorage . removeItem ( 'just:accessToken:' + sdk . config . domain ) ; window . location . reload ( ) ; } ) ; getToken ( false ) . then ( function ( ) { logoutBtn . style . display = '' ; loginBtn . style . display = 'none' ; printInfo ( ) ; } , function ( ) { loginBtn . style . display = '' ; logoutBtn . style . display = 'none' ; } ) ; }
this function is called right after the DOM has loaded
this function is called right after the DOM has loaded