signalpoint / DrupalGap

An application development kit for Drupal websites.
https://www.drupalgap.org
GNU General Public License v2.0
232 stars 185 forks source link

Trying user.login failed for my remote website #2

Closed jchesne closed 11 years ago

jchesne commented 11 years ago

Im using your libraries for a month now without problem in localhost environment. I had a drupal 7 instalation and phonegap project in local too and everything worked fine so i decided to transfert my local drupal7 website to remote serveur.

Everything work fine exept login, when i call for user/login.json in my remote rest server, the response is ok, with all system_connect, site_settings and others data well configured BUT after this when i try to create content with authenticated user, the serveur answer 401 error Unauthorized: Access denied for user anonymous...

Im googled without success.

For information, in local when i use user/login with firefox and i go to my website im automaticaly connected, when i do the same for remote website i'm not connected BUT when i log as admin and check for activity message (in admin/reports/dblog) i can see my user was connected !

So the question is, why does user/login work for local environment and not for remote service ?

(im french, sorry for my english, i tried my best)

Thank in advance.

signalpoint commented 11 years ago

Make sure the 'Session Authentication' checkbox is checked under your Services 'Edit' settings. This will ensure each call is not made by an anonymous user.

Also make sure you are consistent with using www (or not using www) when making the calls.

Making a user login call with www.... then making a content create call without the www will make Services think it is a different user.

On Sun, Sep 9, 2012 at 1:56 PM, jchesne notifications@github.com wrote:

Im using your libraries for a month now without problem in localhost environment. I had a drupal 7 instalation and phonegap project in local too and everything worked fine so i decided to transfert my local drupal7 website to remote serveur.

Everything work fine exept login, when i call for user/login.json in my remote rest server, the response is ok, with all system_connect, site_settings and others data well configured BUT after this when i try to create content with authenticated user, the serveur answer 401 error Unauthorized: Access denied for user anonymous...

Im googled without success.

For information, in local when i use user/login with firefox and i go to my website im automaticaly connected, when i do the same for remote website i'm not connected BUT when i log as admin and check for activity message (in admin/reports/dblog) i can see my user was connected !

So the question is, why does user/login work for local environment and not for remote service ?

(im french, sorry for my english, i tried my best)

Thank in advance.

— Reply to this email directly or view it on GitHubhttps://github.com/signalpoint/DrupalGap/issues/2.

Regards, Tyler Frankenstein

http://www.tylerfrankenstein.com

jchesne commented 11 years ago

Thanks signalpoint for your response, but still not working.

I made a test using exactly the same code as you (drupal code and drupalgap code) and its working for local but not for remote serveur. Tested on firefox, safari and chrome, event in xcode simulator.

I think the problem is user/login.json and cookies or session handler no?

One other information, when i use Poster with firefox 1)login 2)create content everything is ok, the content is created. I dont know where i have done a mistake.

I confirm again, when i change the url of webservices in drupalgap conf from remote to local all works fine, when i swith from local to remote the login fail.

jchesne commented 11 years ago

I just come to upload my entire phonegap drupalgap project to my server, and now it work fine... So the problem is when i try to use webservice when im in localhost and i call remote data.

The problem is not in drupalgap project but more server/services/rest restriction between localhost and remote.

Info : i have added this line of code in my htacces for accpet local call

Header set Access-Control-Allow-Origin * Header set Access-Control-Allow-Methods "GET,POST" Header set Access-Control-Allow-Headers "x-prototype-version,x-requested-with"

signalpoint commented 11 years ago

Sorry for a late follow up. Have you had any luck with this problem? Since my last post in this thread, there has been many updates to the DrupalGap Module Documentation (http://drupal.org/node/1603690) and a 7.x-2.x branch (https://github.com/signalpoint/DrupalGap/branches) has been started here on GitHub with many improvements.

signalpoint commented 11 years ago

I'm going to close this issue as a legacy issue. Be sure to check out the 7.x-1.x branch for the latest code fixes and improvements. Please re-open if you are still having issues with user login.