Thanks @happybeing.
I don’t understand why the response you get from the function window.safeAuth.authorise is the parsed response while the response I get is an object that contains a lot of stuff including the parsed response but under the child-object named _ parsedResponseBody_. In other words, the same function return two different things.
This is the content of what window.safeAuth.authorise returns for me, you can put it inside a json viewer to see it more clearly:
{"__parsedResponseBody__":{"permissions":[],"token":"eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IkFkVll0MEppR3VXN0ZGS1Y1R1Fvc2srZE5VRFcwOC95WGtaRnZKYkduTVU9In0.J7n6V1sdP9cObe7EK-mfwXMtBE3vxfh0Z8RweRPtMqU"},"_abort":false,"_bytes":165,"_raw":[{"type":"Buffer","data":[123,34,116,111,107,101,110,34,58,34,101,121,74,104,98,71,99,105,79,105,74,73,85,122,73,49,78,105,74,57,46,101,121,74,112,90,67,73,54,73,107,70,107,86,108,108,48,77,69,112,112,82,51,86,88,78,48,90,71,83,49,89,49,82,49,70,118,99,50,115,114,90,69,53,86,82,70,99,119,79,67,57,53,87,71,116,97,82,110,90,75,89,107,100,117,84,86,85,57,73,110,48,46,74,55,110,54,86,49,115,100,80,57,99,79,98,101,55,69,75,45,109,102,119,88,77,116,66,69,51,118,120,102,104,48,90,56,82,119,101,82,80,116,77,113,85,34,44,34,112,101,114,109,105,115,115,105,111,110,115,34,58,91,93,125]}],"body":{"_events":{"end":[null]},"_eventsCount":3,"_readableState":{"awaitDrain":0,"buffer":{"head":null,"length":0,"tail":null},"decoder":null,"defaultEncoding":"utf8","emittedReadable":false,"encoding":null,"endEmitted":true,"ended":true,"flowing":true,"highWaterMark":16384,"length":0,"needReadable":false,"objectMode":false,"pipes":null,"pipesCount":0,"ranOut":false,"readableListening":false,"reading":false,"readingMore":false,"resumeScheduled":false,"sync":false},"_transformState":{"needTransform":false,"transforming":false,"writecb":null,"writechunk":null,"writeencoding":"buffer"},"_writableState":{"bufferProcessing":false,"bufferedRequest":null,"bufferedRequestCount":0,"corked":0,"corkedRequestsFree":{"entry":null,"next":null},"decodeStrings":true,"defaultEncoding":"utf8","ended":true,"ending":true,"errorEmitted":false,"finished":true,"highWaterMark":16384,"lastBufferedRequest":null,"length":0,"needDrain":false,"objectMode":false,"pendingcb":0,"prefinished":true,"sync":false,"writecb":null,"writelen":0,"writing":false},"allowHalfOpen":true,"domain":null,"readable":false,"writable":false},"bodyUsed":true,"headers":{"_headers":{"connection":["close"],"content-length":["165"],"content-type":["application/json; charset=utf-8"],"date":["Sun, 06 Nov 2016 18:08:50 GMT"],"etag":["W/\"a5-CRWmf6/5CtRdLV4/vZXv3g\""],"x-powered-by":["Express"]}},"ok":true,"size":0,"status":200,"statusText":"OK","timeout":0,"url":"http://localhost:8100/0.5/auth"}
My authorise code looks like this:
let app = {
name: 'SimpleSafe2',
id: 'davidmtl.simplesafe2',
version: '0.0.1',
vendor: 'davidmtl',
permissions: [],
}
window.safeAuth.authorise(app).then(function(res) {
console.log("Authorize response");
console.log(JSON.stringify(res));
console.log(res.token);
}).catch(function(error_text) {
console.log("ERROR:" + error_text);
});
Any idea @joshuef?