SavaPage RESTful API: questions and answers

SavaPage has a RESTful API. Feedback based on real world use is greatly appreciated. So, please tell us what RESTful services you need.

Hello again,

I’m currently working on a setup where Savapage sources its users from an OpenLDAP server and also delegates authentication to Keycloak for a single-sign-on experience.

Both my Savapage and Keycloak instances use the same backing OpenLDAP instance. I also allow new users to register via Keycloak. Once the user verifies their email address a new user record is added to OpenLDAP.

I have set up Keycloak to publish events to a RabbitMQ broker and I’ve also written some middleware to read those events and process user creations/deletions.

What I would like to do now is programmatically tell Savapage to either:

  • Sync a new specific user from LDAP; or
  • Sync all users from LDAP

Is such funcitonality available from the REST API?

@MetaFight. When you enable “Import new users overnight”, users are automatically synchronized daily at 10 minutes past midnight. In addition you can enable “On demand user creation” to ad-hoc create a user when they successfully login to SavaPage for the first time (“At first login”), or when they print to a SavaPage queue for the first time (“At first print”). It’s all explained in the User Creation section of the User Manual.

Hi,

I’ve tried the settings you suggest but unfortunately, this doesn’t seem to work. Here’s what happens:

  1. User navigates to Savapage login page
  2. User clicks on “login with Keycloak” button
  3. User is directed to Keycloak page
  4. User choses to register a new account
  5. Keycloak asks User to verify their email
  6. User receives a verification email with a verification link
  7. User clicks verification link
  8. Keycloak acknowledges verification, creates local account, and immediately synchronises account with LDAP
  9. OpenIdConnect Authentication was successful, therefore Keycloak redirects user to Savapage
  10. Savapage fails to log user in with error message: Keycloak login failed Try again with another account, or use another method.
    image

However, if I trigger a manual sync with LDAP from the Savapage Admin panel then the login works.

Now I’m wondering if I should remove the link between Savapage and LDAP. Is this necessary now that I have a working SSO setup with Keycloak? Nope, disabling the LDAP User Source doesn’t change anything. I’ll probably just sniff the API call the admin console makes when I manually sync and simulate that.

@MetaFight Please wait before diving too deep. I’m working on a solution to solve your issue right now. Should be ready today/tomorrow. I’ll let you know when its ready for testing.

@MetaFight A new RC snapshot is available with issue 1150: Support OAuth ad-hoc user creation implemented. Can you please test if this solves your problem?

P.S. Set keycloak.savapage.usersource=true in your savapage-ext-oauth-keycloak.properties file.

1 Like

Hi @rijkr,

Your latest build, with the changes you mentioned, works like a charm! thank you!

@MetaFight Thanks for your swift confirmation! Issue 1150 is now marked as resolved :slight_smile:

Hi there - I hope I might revive this old thread

We just recently discovered SavaPage and it seems a near to perfect solution for our school (and others in the same situation). We have developed a billing solution for our copiers on top of the printer quota solution pykota - and it would be perfect to connect SavaPage and our billing system (also open source) as a modern successor.

What we need for that within the RESTful API would be a way to

  • get user details, especially balance (to set copier quota according to the actual user balance in savapage)
  • issue a print job and delegating the costs for it to a certain user (in our old system we print to virtual printers to bill the copies a user made to the printer quota/billing system - this way they could see their copies in their print log).
  • it would also be nice to get the reports as JSON-Data via the RESTful API
    As all of this is easily to achieve usung the the web interface, we have some hope that there is a certain chance to implement this functionality. If there is not we might give python/selenium a try…

In any way thanks for this exciting piece of software.
Best regards
Thomas

Hi @thoschi , welcome to SavaPage! and thanks for your feedback. For starters, to issue a print job by RESTful API, have a look at POST /documents/print to see if that suits your needs. Please contact support@savapage.org so we can discuss your requirements.

Hi,

I’ve just turn on my computer with savapage server already installed and the print portal doesn’t open. I typed the status command and this appeared

savapage.service - SavaPage Open Print Portal
Loaded: loaded (/lib/systemd/system/savapage.service; enabled; vendor pres>
Active: inactive (dead) since Wed 2023-10-04 11:33:55 CST; 17min ago
Process: 14269 ExecStart=/opt/savapage/server/bin/linux-x64/app-server star>
Process: 14345 ExecStop=/opt/savapage/server/bin/linux-x64/app-server stop >
Main PID: 14319 (code=exited, status=0/SUCCESS)
CPU: 1.945s

I tried to start, stop, restart and enable the service, but nothing worked for this. Please, help.

@KGLW Welcome to SavaPage!

Open /opt/savapage/server/logs/server.log and look for ERROR messages. They will give you clues as to what is wrong.

Hi @rijkr !

Our infrastructure uses savapage for remote printing. Thanks for the great work !
I’m currently building a telegram-bot that’d be able to automatically print the files sent to him. To do this, i’m using your RESTful API (can’t include links).
Your doc uses the following :

curl -v -k -u janet:97008e2c-d8b2-11e9-aa13-406186940c49 \
     -H "Content-Type: multipart/form-data" -H "Accept: application/json" \
     -F "file=@lorem-ipsum.txt" -X POST \ 
      https://savapage:8632/restful/v1/documents/print

Which I use with python’s requests module as so:

    print_headers = {
        'Accept': 'application/json'
    }

    files = {
        'file': open(filename, 'rb')
    }

    response = session.post(
        url='https://domain.name/restful/v1/documents/print',
        headers=print_headers,
        files = files,
        # verify = False,
        auth=(user_auth_data['user'], user_auth_data['UUID'])
    )

However, executing this request only uploads the file to my profile.
Is there, to your knowledge, something I’d be missing here ?
We have multiple printers in our infrastructure. Maybe this is the reason ? Is there some way to specify which printer I wish to use or can admins set a “by-default” printer ?

Let me know what you think or if you need more information !

Thanks again.

I wish you a lovely day.

Arthur

@Wilzzer Welcome to SavaPage! Indeed, the RESTful API is just another way to print a file to SavaPage, just like a driver or driverless print: see SavaPage as Printer. Once the print job is committed to SavaPage, you can proceed with so-called Proxy Print Scenarios, to print to a physical printer.

Hi rijkr !

Thanks for your answer. I’m sorry but i’m not sure I understand how these proxy scenarios work in this case. I read all the proxy-print and IPP doc but maybe there’s something i didn’t quite understand.
From the IPP Routing page, I understood that the following should be possible :

  • Upload automatically to a specific queue (how to do that in the POST method ?)
  • Queue is setup with “IPP routing” and its settings print automatically any job sent to this queue (Non-Secure printing)

Alternatively, does any command-line/API instruction exist to execute the printing once it’s uploaded ?

Currently, “standard user” simply connect to the webapp, upload their file and can then issue a printing to a printer of their choice.
In this other scenario, the user sends an image to a telegram-bot, which converts it to a PDF, uploads it and issues the print automatically.

Let me know if you have any hints on the matter !

Thanks again.

Hello again,

I think I got it, let me know if this is correct:

  • Admins can create a specific queue that is IPP routed to a specific printer. This queue can be configured to automatically print what it receives.
  • As RESTful prints to the queue /webservice, this specific queue has to be configured as such. In case it’s needed, can another queue be created to receive RESTful prints ?

Thanks again !

I will implement this feature. It will take a few days. I will let you know when it is ready.

1 Like

Please contact support@savapage.org to discuss implementation.