how to send/POST JWT token from Android to Laravel backend
<p>i wanted to access my back-end using android phone. at this moment i want to do two things:</p>

<ol>
<li>login the mob app after being authenticated from the Back-end.</li>
<li>Upload data to the back-end (back-end is PHP with Laravel Framework). </li>
</ol>

<p>i first send email and password to the backend and gotten back a response of <code>JWT</code> token as shown: </p>

<p>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cLzE5Mi4xNjguMS4xMDI6ODAwMFwvYXBpXC92M1wvYXV0aGVudGljYXRlIiwiaWF0IjoxNDY2MDA5OTY3LCJleHAiOjE0NjYwMTM1NjcsImp0aSI6IjZjYjBlMTRjYTNkMjAzM2Q4OWM0NzM1M2ZjNjMzZTU2In0.GJGUjgy8U-uqjLSqJcysDTmgrNvxBHH03iBflLjsOwA"</p>

<p>Once the above token returned to the mob app, i want to send the same returned token for further post request, because the above jwt token is my key for accessing the back-end.</p>

<p>So my problem lies on sending the same token back to the back-end. it seems simple and stright forward since i have already started to communicate with my back end, and i have also checked my response by using post man.</p>

<p><a href="https://i.stack.imgur.com/QmYvM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QmYvM.jpg" alt="loging in"></a>
</p>

<p>and i can also got the user cridential using the jwt token on postman.</p>

<p><a href="https://i.stack.imgur.com/AAo8m.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AAo8m.jpg" alt="postman receive user cridentials as json"></a>
</p>

<p>now the same token which works on postman is not working for my android. i know that my httpClient and httpPost are working since i have already send the email and password with it. i also know that my android post request is reaching the server since my returned result comes with an error message i built for an accepted token request, as shown below.</p>

<p><a href="https://i.stack.imgur.com/U96c0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U96c0.jpg" alt="when android recives user cridentials as json"></a>
</p>

<p>as you can see from the above snap shot. i first get the token inside a quotation (first highlighted), when posted for authentication. so i removed the quotation and posted the same token for getting user cridential but this time i got an error response which i built it on the Back-end. </p>

<p>so that is why i think my token is not going to the server properly. but i couldn't fix the problem. but i am guessing the token size is big, with a length of 490. so how shall i attach my token with the httpPost request? my code for the building the request is shown below:</p>

<pre><code>public String getJsonString2(String url, String jwtString) {

        String jsonString = "";

        HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        List nameValuePair = new ArrayList(1);
        nameValuePair.add(new BasicNameValuePair("token", jwtString));
        try {
            httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
        }
        catch (UnsupportedEncodingException e) {
            // writing error to Log
            e.printStackTrace();
        }

        // Making HTTP Request
        try {
            HttpResponse response = httpClient.execute(httpPost);
            jsonString = EntityUtils.toString(response.getEntity(), HTTP.UTF_8);

        } catch (ClientProtocolException e) {
            // writing exception to log
            e.printStackTrace();

        } catch (IOException e) {
            // writing exception to log
            e.printStackTrace();
        }

        return jsonString;

    }
</code></pre>

<p>i have also tried using MultipartEntityBuilder for parsing the parameter (token in my case) but the MultipartEnityBuilder library was crasshing my program when building:</p>

<p>the MultipartEnityBuilder library is added to my project using the following dependencies:</p>

<pre><code>//for accessing the MultipartEntity lbrary
compile "org.apache.httpcomponents:httpcore:4.2.4"
compile "org.apache.httpcomponents:httpmime:4.3"
</code></pre>

<p>the error because of the MultipartEntity </p>

<p><a href="https://i.stack.imgur.com/m8H96.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8H96.jpg" alt="build error for the MultipartEntity library "></a>
</p>

<p>So now my question is: 
     how can i send the jwt token value from android to Laravel backend.</p>