Astrocoders / nubank-api

NuBank API - Not related to Nu Pagamentos S.A.
MIT License
666 stars 44 forks source link

Api url has changed #5

Open pedrolauro opened 6 years ago

pedrolauro commented 6 years ago

I've been using this lib for a couple months, with everything ok. Now I'm getting this error:

FetchError: request to https://prod-auth.nubank.com.br/api/token failed, reason: write EPROTO 140736572793792:error:14094412:SSL routines:ssl3_read_bytes:sslv3 alert bad certificate:../deps/openssl/openssl/ssl/s3_ pkt.c:1498:SSL alert number 42 140736572793792:error:1409E0E5:SSL routines:ssl3_write_bytes:ssl handshake failure:../deps/openssl/openssl/ssl/s3_pkt.c:659

I think the api URL has changed to this new url:

https://prod-s0-webapp-proxy.nubank.com.br/api/proxy/AJxL5LBUC2Tx4PB-W6VD1SEIOd2xp14EDQ.aHR0cHM6Ly9wcm9kLWdsb2JhbC1hdXRoLm51YmFuay5jb20uYnIvYXBpL3Rva2Vu

DiogoAngelim commented 6 years ago

Thanks @pedrolauro. How do I get the new API URL for the /registration endpoint?

fakenickels commented 6 years ago

nice! thanks for pointing it out @pedrolauro, I'm going to take a look soon

pedrolauro commented 6 years ago

@digelim Just try to login at Nubank's website and watch for XHR requests into the dev tools Network tab. I found the new URL doing that. Later I just updated the new url on apis_uri.js file and it worked.

fakenickels commented 6 years ago

when I first started doing the API wrapper there was an endpoint that enlisted all the other possible ones, if this one still exists maybe we could use it to always be up to date

pedrolauro commented 6 years ago

After you successfully authenticated with that new url (and also the old one), the response includes a range of api's urls, for all kinds of functions for Nubank. But none for Nuconta, though.. Did you guys have seen any way to integrate with NuConta's API?

Btw, why the hell are we discussing this in english? lol =D

fakenickels commented 6 years ago

Btw, why the hell are we discussing this in english? lol =D I'm always talking in english at work so I'm on default mode haha, also makes sense if any "gringo" will see this in the future.

About the NuConta I don't think they made it public yet, gonna try to dig on that but probably is not allowed (if anyone from NuBank is reading this, please, let us know!)

guilhermedecampo commented 6 years ago

summoning @rafaelcorreiapoli

DiogoAngelim commented 6 years ago

Thanks @grsabreu. One of the urls mentioned by pedrolauro is called "savings". But I don't know how to use that, sorry. There is no documentation :(

RNT17 commented 5 years ago

Quem consegue me ajudar no básico? Quero testar essa API, mas como faço pra executar o script? Editado: Ok, eu fiz uma pergunta muito geral. Resumindo, adicionei o 'nubank' usando o yarn, e estou com um script .js como servidor de teste. O problema é que ta retornando um erro:

createNuBank is not a function

Apontando pra classe createNuBank();

meu código completo:

var http = require('http'),
  host = '127.0.0.1',
  port = '9000';

var server = http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
    res.end("Servidor On!");
    }).listen(port, host, function() {

    console.log('Servidor rodando em http://' + host + ':' + port);

    //import createNuBank from 'nubank'; Não suportado na minha versão do NodeJs
    const createNuBank = require("nubank");
    const NuBank = createNuBank();

    NuBank.getLoginToken({
      password: 'minhasSenha',
      login: 'Meu CPF', // no dashes nor dots!
    }).then(response => console.log(`I'm in!`)) // just need to call this once

});

Detalhe. Não sou familiarizado com o NodeJs.

ggviana commented 5 years ago

@RNT17 Tente usar

const createNuBank = require("nubank").default;
danilobarion1986 commented 5 years ago

There's 2 discovery URI's that can be used to get all API endpoints: https://prod-s0-webapp-proxy.nubank.com.br/api/discovery and https://prod-s0-webapp-proxy.nubank.com.br/api/app/discovery

guilhermedecampo commented 5 years ago

@danilobarion1986 cool man. Can you create a PR for us with this change?

danilobarion1986 commented 5 years ago

@danilobarion1986 cool man. Can you create a PR for us with this change?

I'm developing an automated workflow to get my bills with Ruby because I'm not so familiar with Javascript... When I finish the part of use dynamic URL's I could try to translate it to Javascript and then open a PR here :)

Meanwhile, it's possible to call those endpoints manually and replace them in the code.

dygufa commented 5 years ago

@danilobarion1986 are you considering the qrcode step required to get the "events link"? I'm also trying to use nubank's api to get my purchase list but from what I'm seeing I will have to use: i) discovery links; ii) login link; iii) lift link (which involves reading a qrcode); iv) and finally events link. Do you have a different approach on mind?

danilobarion1986 commented 5 years ago

@danilobarion1986 are you considering the qrcode step required to get the "events link"? I'm also trying to use nubank's api to get my purchase list but from what I'm seeing I will have to use: i) discovery links; ii) login link; iii) lift link (which involves reading a qrcode); iv) and finally events link. Do you have a different approach on mind?

Yes, this is the exact workflow to authenticate. As I said before, I won't be able to make a PR with the javascript code, but I finish my ruby automation (it can be viewed here). Before I made it I tried to use a python automation, but I encounter some errors with it and then decided to roll out my own.

dygufa commented 5 years ago

@danilobarion1986 are you considering the qrcode step required to get the "events link"? I'm also trying to use nubank's api to get my purchase list but from what I'm seeing I will have to use: i) discovery links; ii) login link; iii) lift link (which involves reading a qrcode); iv) and finally events link. Do you have a different approach on mind?

Yes, this is the exact workflow to authenticate. As I said before, I won't be able to make a PR with the javascript code, but I finish my ruby automation (it can be viewed here). Before I made it I tried to use a python automation, but I encounter some errors with it and then decided to roll out my own.

Thanks! I'm already finishing an implementation using Javascript following the workflow described above, however, I'm not sure if it fits this api considering it would be a huge breaking change this new qrcode requirement. It only makes sense in a major release (or maybe not considering it's already broken).

danilobarion1986 commented 5 years ago

Cool @dygufa ! I think that fix the dynamic URI issue and add other login flow, considering QR Code validation, are two different things (If someone is already using login without QR Code, what I don't know if it is possible...).

But if everybody needs a QR Code to log in them I agree with you that is better to launch a new breaking version and deprecate this one

renanbatel commented 4 years ago

Hi, just passing by to say that I decided to create a project to create a JS library for Nubank's API with all the QR Code authentication and stuff. Thanks for your ruby project @danilobarion1986, it was a great help. I already made an npm package for it, you can check it here.

danilobarion1986 commented 4 years ago

Hi, just passing by to say that I decided to create a project to create a JS library for Nubank's API with all the QR Code authentication and stuff. Thanks for your ruby project @danilobarion1986, it was a great help. I already made an npm package for it, you can check it here.

Just saw your comment on the npm lib you wrote, really appreciate man!