1

Handle authorize response of wialon token generator form

Тема: Handle authorize response of wialon token generator form

Hello everyone,
I need to embed wialon authorization form
check it here
to my custom web application
my question is how can i listen to authorize submit event and handle response data like "access_token".

regards,
thanks

2

Handle authorize response of wialon token generator form

Re: Handle authorize response of wialon token generator form

Hello. Add parameter redirect_uri=http://tracking.wenkgps.com/post_message.html or to your own same page, that will emit GET-params via postMessage.

Then listen for postMessages and wait for successfull authorization. We, for example, have such code for authorization handling:

window.addEventListener('message', onWindowMessage);

function onWindowMessage(e) {
    if (!e || !e.data || (typeof e.data !== 'string')) return;
    if (!(/^loginauth:/.test(e.data))) return;

    var json = e.data.slice('loginauth:'.length);

    try {
        json = JSON.parse(json);
    } catch (e) {
        Log.error('oauthPostMessage', e.data);
        return;
    }

    oauthDone(json);
}