Jump to content

Webservices , Mobile Application and Login functionality


Recommended Posts



I'm currently building an Android application that must connect to my Prestashop website.


Here are the functionalities that I must develop :

- Make the users able to login into my app using the same credentials as they have created on the website

- Make new users able to create an account

- Make the user able to see and edit his/her profile

- Make the user able to buy some products directly from my app


In order to do this, I've started to study the Prestashop Webservices. I've been through the different tutorials but I'm having some problem to figure out how to integrate the "login" functionality.


Basically, I just want to check if the Webservice give me a "customer" object when I send a GET method like this :

http://mywebsite.com/api/customers/?filter[email][email protected]&filter[passwd]=my_password

The thing is that the "my_password" value is encrypted in order to be saved securely in the Prestashop database. Thus, in the above request, I need to encrypt, in my app, the user password in order to get the same encrypted value that the one saved in the Prestashop database.


Does anyone know how the password is encrypted?

Am I choosing the correct solution to develop the login functionality?




Edited by Bertrand (see edit history)
Link to comment
Share on other sites

Ok I've found it  :)


The password is encode that way :

md5( '_COOKIE_KEY_' + 'plain text password' );

See this thread for more information : http://www.prestashop.com/forums/topic/30984-password-encryption-psql-function/


The '_COOKIE_KEY_' is located in "settings/settings.inc.php" file of your prestashop folder

Edited by Bertrand (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

hi, excuse me if i write here but i don't believe ii need open new topic.

i'm in difficult because when i create a webservice with my prestashop i can't use it to interface with an app android beacuse it ask me the login, even if I insert the url http://my[email protected]/api/ . can you help me? thank you

Edited by bit_dan (see edit history)
Link to comment
Share on other sites



I also had troubles to figure out how to insert the API token in my HTTP requests.

Here is the code that you have to use in order to be able to deal with the Prestashop WebServices in Android:


First, create the DefaultHttpClient like this (API_AUTH_TOKEN is equal to your "mypasskey"):

DefaultHttpClient client = new DefaultHttpClient();
AuthScope auth = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
UsernamePasswordCredentials apiToken = new UsernamePasswordCredentials(API_AUTH_TOKEN, "");
client.getCredentialsProvider().setCredentials(auth, apiToken);

Then use it as usual for your different HTTP Request.

For instance, here is my method to send HTTP Get request

	 * Generic HTTP GET method sender
	 * HTTP GET must be used to retrieve informations from remote PrestaShop database
	 * @param apiMethod
	 * @return the server response as string. This response must be parsed.
	private String sendHttpGetMethod(String apiMethod){
		String url = BASE_API_URL + "/" + apiMethod;
		HttpGet get = new HttpGet(url);
		HttpResponse responseGet;
		try {
			responseGet = client.execute(get);
			InputStream is = responseGet.getEntity().getContent();
			BufferedReader r = new BufferedReader(new InputStreamReader(is));
			StringBuilder response = new StringBuilder();
			String line;
			while ((line = r.readLine()) != null) {
			return response.toString();
		} catch (ClientProtocolException e) {
			return null;
		} catch (IOException e) {
			return null;

I hope this will help you,



Link to comment
Share on other sites

  • 3 years later...
  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...