lorenzh / fut-api

Ultimate Team API - FIFA 16 - unofficial
MIT License
53 stars 12 forks source link

"unable to login" was logged two times #12

Open turtok opened 8 years ago

turtok commented 8 years ago

Hi, first of all, congratz for your work, of course.

I'm trying to use it, but I cant login. I don't really get that twoFactorCodeCb-function, if I'm honest. First, I replaced the parameter of the next-function inside of the twoFactorCodeCb-function with my Code received via email, and filled the other login parameters with my data. But when I'm accessing my script, It only logs 'Unable to login' two times. I also changed my twoFactor method from email to the app method, and use the code from the app, but still the same result.

What I'm doing wrong? I'm just using the code snippet from the Login-Section of the readme.

Thanks for any help :)

lorenzh commented 8 years ago

hi,

i think you are calling the next method two times. you need to call it when you have received the code and pass the code in to the next method.

turtok commented 8 years ago

Hey, thx for your reply, but I don't call it two times. Here is my Client.js, which I'm calling via my browser, after I started the Client.js from the console with: node Client.js

`var futapi = require("fut-api"); var apiClient = new futapi({ saveCookie: true, saveCookiePath: "cookie.json", loadCookieFromSavePath: true
});

var connect = require('connect'); var server = connect(). use( function(req, res) { res.end('Hello World!');

        apiClient.login("email","password","awnser", "platform",
                twoFactorCodeCb,
                function(error,response){
                    if(error) {
                        return console.log("Unable to login.");
                    }
                    console.log("logged in.");
                    apiClient.getCredits(function(error, response){ });
                }
        );
    }
).listen(64084); 

function twoFactorCodeCb(next){ /* send your authentication code with the "next" method */ next("088592"); }` I'm just typing localhost:64084 into the browser and I'm seeing the logs in the console.

What do you mean with: I need to call the next-method after I received the code? How should I handle that in the code? I'm just trying to insert my code as string into the parameter of the next-method (088592 for example).

LoriKarikari commented 8 years ago

Same problem here... I don't really get that twoFactorCodeCb function. It sends me the code on my phone when I call apiClient.login() but how do I pass the code I received? The twoFactorCodeCb is already called?