Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't make demo code to work but it do authenticate #79

Closed
theycallmetyson opened this issue Jul 5, 2022 · 3 comments
Closed

can't make demo code to work but it do authenticate #79

theycallmetyson opened this issue Jul 5, 2022 · 3 comments

Comments

@theycallmetyson
Copy link

theycallmetyson commented Jul 5, 2022

following the first example it gets successfully authenticated but when it come to the getPositions() i get TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "X-AuthenticationSession". any idea of how to solve it?

require('dotenv').config()
const Avanza = require('avanza')

const avanza = new Avanza()

const credentials = {
    username: process.env.AVANZA_USERNAME,
    password: process.env.AVANZA_PASSWORD,
    totpSecret: process.env.AVANZA_TOTP_SECRET
}

avanza.authenticate(credentials).then(async () => {
    console.log('Authenticated')

    const positions = await avanza.getPositions()
    console.log(positions)

}).catch(err => {
    console.log(err)
})
[nodemon] starting `node ./src/server.js`
Authenticated
TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "X-AuthenticationSession"
    at ClientRequest.setHeader (node:_http_outgoing:606:3)
    at new ClientRequest (node:_http_client:271:14)
    at Object.request (node:https:360:10)
    at C:\Users\tyson.la\Projects\tensai-vexa-api\node_modules\avanza\dist\index.js:53:23
    at new Promise (<anonymous>)
    at request (C:\Users\tyson.la\Projects\tensai-vexa-api\node_modules\avanza\dist\index.js:52:10)
    at C:\Users\tyson.la\Projects\tensai-vexa-api\node_modules\avanza\dist\index.js:934:9
    at new Promise (<anonymous>)
    at Avanza.call (C:\Users\tyson.la\Projects\tensai-vexa-api\node_modules\avanza\dist\index.js:930:12)
    at Avanza.getPositions (C:\Users\tyson.la\Projects\tensai-vexa-api\node_modules\avanza\dist\index.js:600:17) {
  code: 'ERR_HTTP_INVALID_HEADER_VALUE'
}

@fruddq
Copy link

fruddq commented Jul 6, 2022

Have the same problem

@theycallmetyson theycallmetyson closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2022
@filipfellman
Copy link

@theycallmetyson Did you solve this? I get the same error, I have created a issue here #85

@origooo
Copy link

origooo commented May 15, 2024

I had the same issue until I activated 2FA/MFA. For a while, I forgot to actually complete the activation on avanza.se after I got the initial key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants