0

I am trying to append few strings in android, I don't know why after second-string it does not work, the following is the code.

 String code_challenge = CryptoHash.getSHA256(code_verifier);
            Log.d(code_challenge,"Code challange");

            StringBuilder s = new StringBuilder(100);
            s.append(URL);
            s.append(code_verifier);
            s.append("&code_challenge=");
            s.append(code_challenge);
            s.append("&code_challenge_method=S256");


            String OAuthURL = URL + code_verifier + "&code_challenge=" + code_challenge + "&code_challenge_method=S256";
            Log.d(OAuthURL,"test");
            Log.d(s.toString(),"test2");

it is giving me the following result in log.

http://10.0.2.2:4431/OAuth/Login?response_type=code&state=Es0wjDVkhRwQ7kTM2TMPO6EJXoCgk

What's wrong with this code?

Following is the log

2020-03-17 17:08:33.600 15174-15196/com.example.oauthdemo I/ample.oauthdem: Background concurrent copying GC freed 4427(899KB) AllocSpace objects, 4(80KB) LOS objects, 49% free, 1639KB/3MB, paused 5.380ms total 57.233ms
2020-03-17 17:08:33.615 15174-15174/com.example.oauthdemo D/Es0wjDVkhRwQ7kTM2TMPO6EJXoCgkfxNeheKcftc: Code Verifier
2020-03-17 17:08:33.616 15174-15174/com.example.oauthdemo D/236531d42fc589f28f7024f250eb6164764ffd1714057eb95429539eab4d316b: Code challange

    [          1584445113.616 15174:15174 D/http://10.0.2.2:4431/OAuth/Login?response_type=code&state=Es0wjDVkhRwQ7kTM2TMPO6EJXoCgktest

    [          1584445113.616 15174:15174 D/http://10.0.2.2:4431/OAuth/Login?response_type=code&state=Es0wjDVkhRwQ7kTM2TMPO6EJXoCgktest2
2020-03-17 17:08:33.643 15174-15174/com.example.oauthdemo D/OpenGLRenderer: HWUI GL Pipeline

Please help!

5
  • pleas explain more what you want and what went wrong? Commented Mar 17, 2020 at 11:47
  • please add all the logs Commented Mar 17, 2020 at 11:48
  • please check, edited Commented Mar 17, 2020 at 11:51
  • The full string should be like this... 10.0.2.2:4431/OAuth/… Commented Mar 17, 2020 at 11:52
  • you are setting limit to StringBuilder when instantiating the instance, remove the 100 char limit. Commented Mar 17, 2020 at 12:20

2 Answers 2

1

you should remove the limit or increase it

    StringBuilder s = new StringBuilder();

best wishes for you

Sign up to request clarification or add additional context in comments.

1 Comment

remove the length make it default constructor new StringBuilder()
0

The problem is that you are passing arguments to Log.d method in incorrect order. Change to Log.d("test2", s.toString());, because tag you are passing has max symbols restriction

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.