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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Failed to authenticate key Problem
Pages: [1]

Author Topic: Failed to authenticate key Problem  (Read 1062 times)

rjtedge

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Wordpress
  • MySQL version: 5.5.40-cll
  • PHP version: 5.4
Failed to authenticate key Problem
April 22, 2015, 07:37:09 pm
Hi,

I'm just starting to get into CiviCRM development and I am having an issue with using the API. I can access the explorer and try to copy and paste the rest  but keep getting "failed to authenticate key".
I have copied my site key from the civicrm.setting.php file and created an api key for myself in phpmyadmin. I assume I am doing something very basic wrong.

What I have looks like this.
https://mysite.net/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=get&json={"sequential":1,"return":"id","first_name":"Test"}&api_key=mysitekey&key=myapikey

Thanks for any help!

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: Failed to authenticate key Problem
April 22, 2015, 11:17:53 pm
I assume your site key is OK? Your example looks ok to me. Do you have any special characters in your sitekey or apikey that might lead to a misinterpretation? I know I have had some issues with a '+' in a site key once. If you do have special chars, try without first?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

rjtedge

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Wordpress
  • MySQL version: 5.5.40-cll
  • PHP version: 5.4
Re: Failed to authenticate key Problem
April 23, 2015, 03:47:41 am
I've check my api and site key and can't see any special characters.

I am going to try to be completely clear with this, to see if I've done something wrong. The steps I have taken are:

1. opened my civicrm.setting.php file
2. copied the site key from
Code: [Select]
if (!defined('CIVICRM_SITE_KEY')) {
  define( 'CIVICRM_SITE_KEY', x1x1x1x1x1x1x1x1x1x' );
}
3. visited phpmyadmin
4. found my contact id in the civicrm_contact table
5. added an api key to my contact id
6. tried to make it work.

Am I missing anything?


 

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: Failed to authenticate key Problem
April 23, 2015, 03:50:33 am
Does the user you have set the api_key for have the right authorisation? I think this should be either Use CiviCRM or use AJAX API
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

rjtedge

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Wordpress
  • MySQL version: 5.5.40-cll
  • PHP version: 5.4
Re: Failed to authenticate key Problem
April 23, 2015, 05:58:11 am
How would I check that?

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: Failed to authenticate key Problem
April 23, 2015, 06:02:59 am
The permission will be set in your CMS? At least, that how it works when I do this with Drupal :-)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Re: Failed to authenticate key Problem
April 29, 2015, 05:38:11 am
Quote from: rjtedge on April 23, 2015, 03:47:41 am

...
2. copied the site key from
Code: [Select]
if (!defined('CIVICRM_SITE_KEY')) {
  define( 'CIVICRM_SITE_KEY', x1x1x1x1x1x1x1x1x1x' );
}
...
Am I missing anything?


I know its kinda obvious, but that code is only setting the site key if it is not already defined. Do you have CIVICRM_SITE_KEY defined anywhere else? 

The lack of a leading quote for the value is presumably just in your post not your actual file ...

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Failed to authenticate key Problem

This forum was archived on 2017-11-26.