[Freeipa-users] First tests against the REST/JSON API

Alexander Bokovoy abokovoy at redhat.com
Mon Nov 9 20:44:38 UTC 2015


On Mon, 09 Nov 2015, Oliver Dörr wrote:
>Hi,
>
>I'm completly new to this list and the product behind it. I'm trying 
>to use perl to get a list from my IPA installation of all users that 
>are on the server.
>
>
>
>#!/usr/bin/perl
>
>use strict;
>use REST::Client;
>use JSON;
>use Data::Dumper;
>use MIME::Base64;
>
>my $username="admin";
>my $password="secret";
>my $headers= {
>    'Accept' => 'application/json',
>    'Content-Type' => 'application/x-www-form-urlencoded',
>    'Authorization' => 'Basic',
>    'user' => encode_base64($username),
>    'password' => encode_base64($password)
>    #encode_base64($username.":".$password)
>};
>
>my $client=REST::Client->new();
>$client->setHost("https://ipa.kreditwerk.de");
>$client->POST("/ipa/session/login_password", $headers);
>print Dumper $client->responseContent();
>
>Sadly I get back
>$VAR1 = '500 Not a SCALAR reference
>';
>
>
>I can't find any hinside the error log of the apache, even with debug 
>enabled. I can't find  any thing in the internet that helps me. 
>(Perhaps I do not know where to look for).
>
>So any idea where I should look at it to troubleshoot this problem?
You are doing it wrong :)

Have you read my blog article?
https://vda.li/en/posts/2015/05/28/talking-to-freeipa-api-with-sessions/

You need to:
 - present referer pointing back to IPA server
 - use correct accept header as 'text/plain' for session password logon
 - pass username and password in the body of the request, not header,
   encoded ias form parameters 'user' and 'password'

Attached is a simple example that works.

-- 
/ Alexander Bokovoy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dumpipa.pl
Type: application/x-perl
Size: 673 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-users/attachments/20151109/0f897157/attachment.pl>


More information about the Freeipa-users mailing list