Acess api resurces after login in android

Hi,

I used the following uri to login from android app.
https://dpipune.erpnext.com/api/method/login?usr=sagarmadke2390@gmail.com&pwd=######

I get correct response. But when I try to access next uri:
http://dpipune.erpnext.com/api/resource/Item”;
I get Authentication failed error. I am using volley library for accessing api.
Can you please tell me how does the server identifies that same user had sent the request to access the next resource.

String jsonUrl ="http://dpipune.erpnext.com/api/resource/Item";
//
        // String id=jsonArrayRequest.getIdentifier();
        jsonArrayRequest = new JsonObjectRequest(jsonUrl,

                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {


                        try {
                            //JSONObject obj = new JSONObject();
                            msg = response.getString("message");
                            Map<String,String> h;
                            h=    jsonArrayRequest.getHeaders();
                            //   Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();

                            if (msg.equalsIgnoreCase("Logged In")) {
                                islogged = true;
                                if (islogged) {

                                }
                                Toast.makeText(getApplicationContext(), "You are logged in as " + response.getString("full_name"), Toast.LENGTH_LONG).show();
                                // call AsynTask to perform network operation on separate thread


                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }


                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                        Toast.makeText(getApplicationContext(), "Hi I am an error" + error, Toast.LENGTH_LONG).show();

                    }
                });

        requestQueue = Volley.newRequestQueue(this);

        requestQueue.add(jsonArrayRequest);
1 Like

you need cookies


Recommended not to keep credentials in mobile app.

Explore OAuth2, http://frappe.github.io/frappe/user/en/guides/integration/

1 Like

Or you need access token

1 Like

Hi,

Thank you sir for reply.
Resolved the issue using session id and cookies