Closed nicolaspernoud closed 5 years ago
Just in case someone would want to have a look, I could provide him/her with some credentials to test the access.
Found it : it seems that the replay library strip the Content-Type and Content-Length header that I need. It works better with the altered initReplay function in standalone.js altered as to not load replay at all when replay option is not set :
function initReplay() {
const replayOption = ['record', 'replay'].find(opt => program[opt] === true)
if (replayOption) process.env.REPLAY = replayOption
if (process.env.REPLAY) require('replay')
}
@nicolaspernoud It is weird because the replay module is required only if --replay or --record options are given to the yarn standalone command. Did you use these options ?
No, I didn't. But the replay module is required anyway (albeit turned into "bloody" mode which should not do anything) : here the original code which require replay (https://github.com/konnectors/libs/blob/master/packages/cozy-jobs-cli/src/standalone.js) :
function initReplay() {
const replayOption = ['record', 'replay'].find(opt => program[opt] === true)
if (replayOption) process.env.REPLAY = replayOption
process.env.REPLAY =
replayOption || (process.env.REPLAY ? process.env.REPLAY : 'bloody')
require('replay')
}
My alteration disable requiring replay instead of turning bloody mode. I didn't do a pull request because I am not sure of possible side effects, but if you want, I can do it... Or you could alter the code directly.
I do not see any side effect. Here is the PR
Thanks @nicolaspernoud :+1:
It would seem that the require('replay')
line is still called anyway in your code. Line 69 should be removed !?.
Sorry. Now this should be ok
Thanks !
If I run the following code with
node .
, it works flawlesslyresponse is
But if I try to put it in a konnector start function and launch it with
yarn standalone
, the auth fails (redirection loop), event if the logged request is exactly the same : Code :Logged request :
Does konnector alter the working of request-promise in any way ?
PS : The
SunQueryParamsString: 'cmVhbG09cGFydGljdWxpZXJz'
bit reference a hidden field<input type="hidden" name="SunQueryParamsString" value="cmVhbG09cGFydGljdWxpZXJz" />
in the authentication page. It would be better to fetch the value of this field with cheerio in case it changes. I'm writing this just in case someone would be interested in writting a connector based on my code...