nubank-api icon indicating copy to clipboard operation
nubank-api copied to clipboard

Api url has changed

Open pedrolauro opened this issue 6 years ago • 19 comments

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

pedrolauro avatar Jun 25 '18 16:06 pedrolauro

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

DiogoAngelim avatar Jun 26 '18 05:06 DiogoAngelim

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

fakenickels avatar Jun 26 '18 12:06 fakenickels

@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.

pedrolauro avatar Jun 26 '18 13:06 pedrolauro

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

fakenickels avatar Jun 26 '18 13:06 fakenickels

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

pedrolauro avatar Jun 26 '18 14:06 pedrolauro

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!)

fakenickels avatar Jun 26 '18 14:06 fakenickels

summoning @rafaelcorreiapoli

guilhermedecampo avatar Jun 26 '18 14:06 guilhermedecampo

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 :(

DiogoAngelim avatar Jun 26 '18 16:06 DiogoAngelim

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.

RNT17 avatar Dec 12 '18 21:12 RNT17

@RNT17 Tente usar

const createNuBank = require("nubank").default;

ggviana avatar Feb 28 '19 18:02 ggviana

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

danilobarion1986 avatar Jun 08 '19 23:06 danilobarion1986

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

guilhermedecampo avatar Jun 09 '19 00:06 guilhermedecampo

@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.

danilobarion1986 avatar Jun 09 '19 02:06 danilobarion1986

@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?

dygufa avatar Jun 10 '19 01:06 dygufa

@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.

danilobarion1986 avatar Jun 10 '19 03:06 danilobarion1986

@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).

dygufa avatar Jun 10 '19 13:06 dygufa

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

danilobarion1986 avatar Jun 10 '19 14:06 danilobarion1986

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.

renanbatel avatar Apr 05 '20 01:04 renanbatel

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!

danilobarion1986 avatar Jul 14 '20 15:07 danilobarion1986