CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • cannot authenticate via the REST api
Pages: [1]

Author Topic: cannot authenticate via the REST api  (Read 2078 times)

ehanuise

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.49-3
  • PHP version: 5.3.3-7+squeeze3
cannot authenticate via the REST api
June 28, 2012, 02:07:34 am
Hi.
I am trying to get the civisync outlook plugin to work, and it always fail at the authentication level.
I have an access denied in the watchdog dblog, and it looks like there's a problem authenticating with the REST api.

I've manually tried various URL formats (see below), and all give me an access denied (user is identified as 'anonymous - not verified').

I've set access ajax api to allowed for anonymous users, no change.
I'm running out of ideas, where should I look to get more info ?

(I tried with and without the api_key in addition to the key parameters.
I use the api key and the user key that have been generated by civisync.

Code: [Select]
mycrmsite_url.dom/civicrm/sites/all/modules/civicrm/extern/rest.php?q=civicrm/login&name=test@test.org&pass=XXXXXXXX&key=XXXXXXXXXXXX&api_key=XXXXXXXXXX&json=1&version=2

mycrmsite_url.dom/civicrm/sites/all/modules/civicrm/extern/rest.php?civicrm/login&name=test@test.org&pass=XXXXXXXX&key=XXXXXXXXXXXX&api_key=XXXXXXXXXX&json=1&version=2

mycrmsite_url.dom/civicrm/sites/all/modules/civicrm/extern/rest.php?q=civicrm/login&name=test@test.org&pass=XXXXXXXX&key=XXXXXXXXXXXX&api_key=XXXXXXXXXX&json=1&version=3

mycrmsite_url.dom/civicrm/sites/all/modules/civicrm/extern/rest.php?civicrm/login&name=test@test.org&pass=XXXXXXXX&key=XXXXXXXXXXXX&api_key=XXXXXXXXXX&json=1&version=3

mycrmsite_url.dom/civicrm/sites/all/modules/civicrm/extern/rest.php?q=civicrm/login&name=test@test.org&pass=XXXXXXXX

mycrmsite_url.dom/civicrm/sites/all/modules/civicrm/extern/rest.php?q=civicrm/login&name=test@test.org&pass=XXXXXXXX
« Last Edit: June 28, 2012, 02:23:50 am by ehanuise »

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: cannot authenticate via the REST api
June 28, 2012, 05:46:14 am
Hi,

On the latest versions, you don't need to authenticate (login) first, you can directly call

rest.php?entity=contact&action=get&key=xxx&api_key=YYY

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ehanuise

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.49-3
  • PHP version: 5.3.3-7+squeeze3
Re: cannot authenticate via the REST api
June 28, 2012, 06:02:13 am
Thanks.
I tried
http://my_site.url/civicrm/sites/all/modules/civicrm/extern/rest.php?entity=contact&action=get&key=XXXX&api_key=YYY
and still : access denied. (user is 'Anonymous (not verified)' )

(substituted xxx and yyy with the site key and user key, and swapped them to make sure it was the right key at the right place.)

Is there a way to get more log info and to know why the access is denied ?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: cannot authenticate via the REST api
June 28, 2012, 06:36:18 am
The contact having the key must have access to civicrm, not anonymous.

We don't display too much information about why an access is denied, for security reasons

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ehanuise

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.49-3
  • PHP version: 5.3.3-7+squeeze3
Re: cannot authenticate via the REST api
June 28, 2012, 07:27:23 am
The contact has access, but in the dblog I see that drupal doesn't recognize the contact and sees it as anoymous.
It makes sense to hide error info from users, but not from the admin of the site, no ? ???

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: cannot authenticate via the REST api
June 28, 2012, 11:11:08 am
What do you see on the screen?

I'm not sure I understand your point about admins, if it fails authenticating you, it can't know you are admin.

I'm not sure if/how drupal is involved in the login, you might want to debug (starting from the rest.php and see what is called)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ehanuise

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.49-3
  • PHP version: 5.3.3-7+squeeze3
Re: cannot authenticate via the REST api
July 02, 2012, 12:29:26 am
Quote from: xavier on June 28, 2012, 11:11:08 am
What do you see on the screen?

I'm not sure I understand your point about admins, if it fails authenticating you, it can't know you are admin.

I'm not sure if/how drupal is involved in the login, you might want to debug (starting from the rest.php and see what is called)


OK I must have madz a bad choice of words, so I'll restate it otherwise for clarity :

- Using the rest.php url call, I cannot login into the system.
- A call to http://my_site.url/civicrm/sites/all/modules/civicrm/extern/rest.php?entity=contact&action=get&key=XXXX&api_key=YYY should log me in Drupal and civicrm and diplay the results of the query, right ?
- All such calls result in 'access denied'
- when I log into Drupal / Civicrm as admin user, and check the dblog to get more info on why the attempt resulted in access denied, all I get is 'anonymous user tried to access this url, access denied'.

So my question is : as admin of the drupal/civicrm, where can I get more info on what happened exactly ? Is there some extended logging feature on calls to the rest.php api that would allow me to trace what data it receives, how it attempts to process it and most importantly why it does fail ?

As stated above, it does make sense to return  miniml error message to an unknown user trying to log in via the rest.php api, but when I log in as admin of the system, I want to get extensive logs about wht has happened.

its this better worded ?

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: cannot authenticate via the REST api
July 02, 2012, 10:55:01 am
Totally better worded, unfortunately there are no extensive logs to my knowledge. You will be best off trying to debug, starting with the rest.php as Xavier suggested. And yes, it would be a very good idea to have extensive logs....we'd cheer you on if you want to start on it  ;D
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

ehanuise

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.49-3
  • PHP version: 5.3.3-7+squeeze3
Re: cannot authenticate via the REST api
July 03, 2012, 02:17:24 am
As stated before I'm no programmer. I'm a good sysadmin, but can't help with code  :'(

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: cannot authenticate via the REST api
July 03, 2012, 02:19:37 am
Well...good sysadmins are pretty important too  ;D
Seriously, you could suggest the logging as a Make It Happen initiative? (look here for more info http://civicrm.org/participate/mih
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

ehanuise

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.49-3
  • PHP version: 5.3.3-7+squeeze3
Re: cannot authenticate via the REST api
July 03, 2012, 02:51:15 am
There's no way I can justify this with my client, especially at a time they're questionning the choice of civicrm in the first place.

lesley

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 1
Re: cannot authenticate via the REST api
December 12, 2013, 05:13:57 am
Don't know if you're still working on this but Eileen provided the following which helped me display errors
Add this to php file
"ini_set('display_errors', 'On');

Apparently works in some but not all instances, but it saved my bacon so good luck.

Let me know how you go as I'm interested in the whole civicsync thing

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: cannot authenticate via the REST api
December 15, 2013, 11:31:52 am
You have a pretty old version, can you try to upgrade? and your client might be happier with a more recent civicrm too ;)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • cannot authenticate via the REST api

This forum was archived on 2017-11-26.