Because the App is for the international market, it needs to access many three-party login SDKS. Twitter login access for a long time, has been no problem. One day, QA came to me suddenly and told me that the authentication failed when I used his phone to log in to Twitter, even the online test version was not working. But it’s ok to use my own phone. This is amazing, because our project has componentization, and the three-party login module is put forward as a separate module. The error message from the lower level is not seen, and only a -1 is returned to the upper level. Then, the client displays an authentication failure message. This hole has time to fill in >_>

solution

Done Three-way login to the shared library, then take a look at what happens when twitter logins fail, then open that class in the main project, Debug all the failed locations, and you’ll see what happens.

Call<User> call = TwitterCore.getInstance().getApiClient(session).getAccountService().verifyCredentials(true.true.false);
        call.enqueue(new Callback<User>() {
            public void failure(TwitterException e) {
                LoginTWProvider var10001 = TwitterActivity.this.mPrivider;
                e.printStackTrace();
                TwitterActivity.this.doFinish();
            }

            public void success(Result<User> userResult) {
                User user = (User)userResult.data;
                LoginTWProvider var10001;
                if (user == null) {}}}); }Copy the code

Twitter login process is to authenticate -> authentication succeeded -> obtain user information (profile picture)

Error 401 is reported when twittercore.getInstance ().getapiclient (session).getAccountService().VerifyCredentials interface is invoked after authentication succeeds.

com.twitter.sdk.android.core.TwitterApiException: HTTP request failed, Status: 401

Did you think it was Twitter? You can just talk to QA. It’s not our problem, third party excuse 401 mistake, we can’t solve. Wait, why your own phone is good, some other phones are ok, only QA this phone has a problem? Do you recommend him to get a new phone? Still have a look, and then went to the network search, as expected there is a pit. This is because QA changed the system time to a very early date in order to test a feature, which caused the certificate to expire. Check QA’s phone, sure enough, call me at………… More than N words are omitted here

conclusion

Because the QA test changed the system time, the third party interface was called 401, and then the login failed, change the phone time, it is ok…

review

1. When logging in to the component library, -1 is thrown in no matter what errors occur. No specific information or error message is displayed. I remember that the team members used to put twitter initialization in the child thread when they were doing project optimization, but there was a problem with the child thread, which led to the failure of Twitter initialization, and the authentication failure was prompted when they logged in. It was also pulled code analysis, and then found the problem… 2. When the client encounters this special case of mobile phone, first check whether there is any problem with the mobile phone. For example: Kiss, I suggest you change a mobile phone!! It saves a lot of time.

Ok, so that’s the end of the day. Write down some of the problems I encountered during the development. If it helps you, please click 👍.