Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unexpected char 0x0a at 58 in Authorization value

ANSWERED

Hi,

   I'm using retrofit for getting Access token,Here is my android code,Error is added at top.Please check this.

 

String basic = "228K7X:1f92e3efa01658587abf868ddc6fd284";
String clientIdclientSecret = null;
//Get Refresh Token here
try {
clientIdclientSecret= Base64.encodeToString(basic.getBytes(), Base64.DEFAULT);
} catch (Exception e) {
e.printStackTrace();
}

System.out.println("clientIdclientSecret " + clientIdclientSecret);

AuthTokenRequest authTokenRequest = new AuthTokenRequest();

authTokenRequest.setCode(code);
authTokenRequest.setRedirect_uri("http://www.chronicwatch.com/");
authTokenRequest.setClientId("228K7X");
authTokenRequest.setGrant_type("authorization_code");

AuthApiInterface apiInterface = ApiClient.getClient().create(AuthApiInterface.class);
Log.i(TAG,"Auth ? "+"Basic "+clientIdclientSecret);
Log.i(TAG,"Content type ? "+"application/x-www-form-urlencoded");
Log.i(TAG,"authTokenRequest ? "+"authTokenRequest "+new Gson().toJson(authTokenRequest));
Call<AuthToken> authTokenCall = apiInterface.getToken("Basic "+clientIdclientSecret,"application/x-www-form-urlencoded",authTokenRequest);

Where getToken is

 

@POST("oauth2/token")
public Call<AuthToken> getToken(@Header("Authorization") String autho, @Header("Content-Type") String contentType, @Body AuthTokenRequest getAuthToken);

 

 

 I'm getting Error like this:

 

java.lang.IllegalArgumentException: Unexpected char 0x0a at 58 in Authorization value: Basic MjI4SzdYOjFmOTJlM2VmYTAxNjU4NTg3YWJmODY4ZGRjNmZkMjg0

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

@Gondwana , Thanks for your reply

View best answer in original post

Best Answer
0 Votes
3 REPLIES 3

This Issue is Fixed By doing

 

String auth_header = ("Basic "+clientIdclientSecret).toString().trim();
Best Answer
0 Votes

Glad you fixed it, but just in case...

0x0A is a line-feed character, which is placed at the end of text lines (sometimes with CR 0x0D) in some operating systems. If you're seeing spurious 0x0A, it could be because something is configured for the wrong operating system. An example of when this can happen is when files are copied using ftp (or equivalent), and the relevant end-of-line conversion isn't done correctly.

Peter McLennan
Gondwana Software
Best Answer

@Gondwana , Thanks for your reply

Best Answer
0 Votes