API token_init problem

23 views
Skip to first unread message

Vasily Yanov

unread,
Mar 18, 2016, 9:39:55 AM3/18/16
to privacyidea
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.

Cornelius Kölbel

unread,
Mar 18, 2016, 9:52:16 AM3/18/16
to priva...@googlegroups.com
Please read this
https://www.privacyidea.org/getting-help/
and you will probably find the solution yourself.

Kind regards
Cornelius
> --
> Please read the blog post about getting help
> https://www.privacyidea.org/getting-help/.
>
> For professional services and consultancy regarding two factor
> authentication please visit
> https://netknights.it/en/leistungen/one-time-services/
>
> In an enterprise environment you should get a SERVICE LEVEL AGREEMENT
> which suites your needs for SECURITY, AVAILABILITY and LIABILITY:
> https://netknights.it/en/leistungen/service-level-agreements/
> ---
> 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...@googlegroups.com.
> To post to this group, send email to priva...@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
corneliu...@netknights.it
+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

Vasily Yanov

unread,
Mar 18, 2016, 10:08:12 AM3/18/16
to privacyidea
Ok.

3. Ubuntu 14.04
4. Ubuntu packages
5. 2.10
6. Mysql 5.5
7. Nginx
8. 

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 написал:

Vasily Yanov

unread,
Mar 18, 2016, 10:24:29 AM3/18/16
to privacyidea
Fixed!

I just modify script in the following way:

#$headr[] = 'Content-type: application/json';
$headr[] = 'Accept: application/json';
 

Cornelius Kölbel

unread,
Mar 19, 2016, 1:22:55 AM3/19/16
to Vasily Yanov, privacyidea
Great.
Thanks for the feedback.



Cornelius Kölbel
+49 151 2960 1417

NetKnights GmbH
Landgraf-Karl-Str. 19, 34131 Kassel, Germany

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


-------- Ursprüngliche Nachricht --------
Von: Vasily Yanov <vasily...@gmail.com>
Datum: 18.03.2016 15:24 (GMT+01:00)
An: privacyidea <priva...@googlegroups.com>
Betreff: [privacyidea] Re: API token_init problem
--
Please read the blog post about getting help
https://www.privacyidea.org/getting-help/.
 
For professional services and consultancy regarding two factor authentication please visit
https://netknights.it/en/leistungen/one-time-services/
 
In an enterprise environment you should get a SERVICE LEVEL AGREEMENT which suites your needs for SECURITY, AVAILABILITY and LIABILITY:
https://netknights.it/en/leistungen/service-level-agreements/
---
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...@googlegroups.com.
To post to this group, send email to priva...@googlegroups.com.
Visit this group at https://groups.google.com/group/privacyidea.
Reply all
Reply to author
Forward
0 new messages