API token_init problem

Hi! I want to import new token with well-known seed, pin and count values
using PI API. But when I try to POST values with php code:

$headr = array();
$headr[] = ‘Content-type: application/json’;
$headr[] = 'Authorization: '.$auth_token;

$post = array(
‘otpkey’ => ‘d6f66965821434f2027e0ea4f597890f7d5c8067’,
‘genkey’ => 0,
‘keysize’ => 20,
‘description’ => ‘Imported’,
‘serial’ => ‘NEW001’,
‘pin’ => ‘1234’,
‘user’ => ‘CN=TEST,OU=Users,DC=corp,DC=org,DC=local’,
‘realm’ => ‘otp.local’,
‘type’ => ‘HOTP’,
‘otplen’ => 6,
‘hashlib’ => ‘sha1’,
);

$ch = curl_init(‘http://otp.local/token/init’);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 11);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

I got an error:

string(836) “{“jsonrpc”: “2.0”, “signature”:
“416313853894912787097973931170705837079917015657189350688759404060679104525563606443716509515745966875145268092143786557757425558662438399357315073703514740503664051108933966549092954944961529792489834816779766607887907054329117011924496836058038351099056637398692128751679056146917423520694096970535895835522168052793184069496892254386045030611004433336729095498778382849043271000313278066167225816174572142563929969337187421854605716177180273144414992014532430973258029148566750140593980873630097129070845551607591721914947910794275967911360168737478065973218911333807737691632843124915882344144184815601083599558”,
“detail”: null, “version”: “privacyIDEA 2.10”, “result”: {“status”: false,
“error”: {“message”: “ERR905: Missing parameter: ‘otpkey’”, “code”: 905}},
“time”: 1458307910.744166, “id”: 1}”

So Missing parameter: ‘otpkey’ but it’s present in initial request moreover
I saw it in tcpdump. How I need to pass otpkey to avoid such error?

BR, Vasily.

Please read this
https://www.privacyidea.org/getting-help/
and you will probably find the solution yourself.

Kind regards
CorneliusAm Freitag, den 18.03.2016, 06:39 -0700 schrieb Vasily Yanov:

Hi! I want to import new token with well-known seed, pin and count
values using PI API. But when I try to POST values with php code:

$headr = array();
$headr = ‘Content-type: application/json’;
$headr = 'Authorization: '.$auth_token;

$post = array(
‘otpkey’ => ‘d6f66965821434f2027e0ea4f597890f7d5c8067’,
‘genkey’ => 0,
‘keysize’ => 20,
‘description’ => ‘Imported’,
‘serial’ => ‘NEW001’,
‘pin’ => ‘1234’,
‘user’ => ‘CN=TEST,OU=Users,DC=corp,DC=org,DC=local’,
‘realm’ => ‘otp.local’,
‘type’ => ‘HOTP’,
‘otplen’ => 6,

'hashlib'      => 'sha1',

);

$ch = curl_init(‘http://otp.local/token/init’);

curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 11);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

I got an error:

string(836) “{“jsonrpc”: “2.0”, “signature”:
“416313853894912787097973931170705837079917015657189350688759404060679104525563606443716509515745966875145268092143786557757425558662438399357315073703514740503664051108933966549092954944961529792489834816779766607887907054329117011924496836058038351099056637398692128751679056146917423520694096970535895835522168052793184069496892254386045030611004433336729095498778382849043271000313278066167225816174572142563929969337187421854605716177180273144414992014532430973258029148566750140593980873630097129070845551607591721914947910794275967911360168737478065973218911333807737691632843124915882344144184815601083599558”, “detail”: null, “version”: “privacyIDEA 2.10”, “result”: {“status”: false, “error”: {“message”: “ERR905: Missing parameter: ‘otpkey’”, “code”: 905}}, “time”: 1458307910.744166, “id”: 1}”

So Missing parameter: ‘otpkey’ but it’s present in initial request
moreover I saw it in tcpdump. How I need to pass otpkey to avoid such
error?

BR, Vasily.


Please read the blog post about getting help
Getting help – privacyID3A.

For professional services and consultancy regarding two factor
authentication please visit
One Time Services - NetKnights - IT-Sicherheit - Zwei-Faktor-Authentisierung - Verschlüsselung

In an enterprise environment you should get a SERVICE LEVEL AGREEMENT
which suites your needs for SECURITY, AVAILABILITY and LIABILITY:
privacyIDEA Support Level

You received this message because you are subscribed to the Google
Groups “privacyidea” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to privacyidea+unsubscribe@googlegroups.com.
To post to this group, send email to privacyidea@googlegroups.com.
Visit this group at https://groups.google.com/group/privacyidea.
To view this discussion on the web visit
https://groups.google.com/d/msgid/privacyidea/f5a20b4f-30d3-4de2-9e73-3b9ae9a36d19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Cornelius Kölbel
@cornelinux
+49 151 2960 1417

NetKnights GmbH
http://www.netknights.it
Landgraf-Karl-Str. 19, 34131 Kassel, Germany
Tel: +49 561 3166797, Fax: +49 561 3166798

Amtsgericht Kassel, HRB 16405
Geschäftsführer: Cornelius Kölbel

signature.asc (836 Bytes)

Fixed!

I just modify script in the following way:

#$headr = ‘Content-type: application/json’;
$headr = ‘Accept: application/json’;

Ok.

  1. Ubuntu 14.04
  2. Ubuntu packages
  3. 2.10
  4. Mysql 5.5
  5. Nginx

import logging
SUPERUSER_REALM = [‘iddqd’]
PI_ENCFILE = ‘/etc/privacyidea/enckey’
PI_AUDIT_KEY_PRIVATE = ‘/etc/privacyidea/private.pem’
PI_AUDIT_KEY_PUBLIC = ‘/etc/privacyidea/public.pem’
PI_LOGFILE = ‘/var/log/privacyidea/privacyidea.log’
PI_LOGLEVEL = logging.INFO
PI_LOGCONFIG = “/etc/privacyidea/logging.cfg”

PI_PEPPER = ‘123’
SECRET_KEY = ‘123’
SQLALCHEMY_DATABASE_URI = ‘mysql://…’
PI_CSS = ‘/static/custom/css/custom.css’

p.9 and 10 is already described.пятница, 18 марта 2016 г., 15:39:55 UTC+2 пользователь Vasily Yanov написал:

Hi! I want to import new token with well-known seed, pin and count values
using PI API. But when I try to POST values with php code:

$headr = array();
$headr = ‘Content-type: application/json’;
$headr = 'Authorization: '.$auth_token;

$post = array(
‘otpkey’ => ‘d6f66965821434f2027e0ea4f597890f7d5c8067’,
‘genkey’ => 0,
‘keysize’ => 20,
‘description’ => ‘Imported’,
‘serial’ => ‘NEW001’,
‘pin’ => ‘1234’,
‘user’ => ‘CN=TEST,OU=Users,DC=corp,DC=org,DC=local’,
‘realm’ => ‘otp.local’,
‘type’ => ‘HOTP’,
‘otplen’ => 6,
‘hashlib’ => ‘sha1’,
);

$ch = curl_init(‘http://otp.local/token/init’);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 11);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

I got an error:

string(836) “{“jsonrpc”: “2.0”, “signature”:
“416313853894912787097973931170705837079917015657189350688759404060679104525563606443716509515745966875145268092143786557757425558662438399357315073703514740503664051108933966549092954944961529792489834816779766607887907054329117011924496836058038351099056637398692128751679056146917423520694096970535895835522168052793184069496892254386045030611004433336729095498778382849043271000313278066167225816174572142563929969337187421854605716177180273144414992014532430973258029148566750140593980873630097129070845551607591721914947910794275967911360168737478065973218911333807737691632843124915882344144184815601083599558”,
“detail”: null, “version”: “privacyIDEA 2.10”, “result”: {“status”: false,
“error”: {“message”: “ERR905: Missing parameter: ‘otpkey’”, “code”: 905}},
“time”: 1458307910.744166, “id”: 1}”

So Missing parameter: ‘otpkey’ but it’s present in initial request
moreover I saw it in tcpdump. How I need to pass otpkey to avoid such error?

BR, Vasily.