icastillejogomez / degiro-api

Unofficial DeGiro stock broker API. See your portfolio and set up orders in the market like wall street
MIT License
195 stars 29 forks source link

Credentials are only taken from env vars #47

Closed luixal closed 1 year ago

luixal commented 1 year ago

Hi,

I tried to make this code work:

const DeGiro = require('degiro-api').default

const username = 'myUsername';
const password = 'myPassword';

const degiro = new DeGiro({ username, password });

(async() => {
  console.log(`Logging in as ${process.env.DEGIRO_USER}...`);
  const data = await degiro.login();

  const jsessionId = degiro.getJSESSIONID();
  console.log(`Logged. Session ID: ${jsessionId}`);
  console.log(data);
})()

and got and error telling me that login needed credentials:

Error: DeGiro api needs an password to access

I got the same error when using the create function.

The only way I've made it work is by using env vars DEGIRO_USER and DEGIRO_PWD.

Any idea about how to make it work with constructor params?

Thanks!

danielvandenberg95 commented 1 year ago

Hi luixal,

I see that this question is answered in an example at the readme. I'd recommend starting with the examples there, and changing as little as possible, one step at a time.

luixal commented 1 year ago

Hi @danielvandenberg95 ,

I always get started with the examples. I took this code from the readme:

// Basic degiro init
const degiro = new DeGiro({
  username: '<your_username_here>',
  pwd: '*****'
})

// or creating with the static create method
const degiro = DeGiro.create({ username: '*****', pwd: '*****' })

// or create with env credentials
const degiro = new DeGiro() // <-- Use DEGIRO_USER & DEGIRO_PWD

The first two ways throw that error about the need for a password, only the last example works for me.

Do you have any code that works for you passing username and password as params?

Thanks!

luixal commented 1 year ago

Just closing this as it was totally my stupidity mixing param names.

Sorry!