the Perl variable, $headers, includes the following which are required for every API call:

  • Content-type: application/json
  • X-Okapi-Tenant: fs[in our case this is an 8-digit long number]
  • X-Okapi-Token: [a very long string that is a combination of numbers and upper & lowercase letters and then some]

the first two details are static - the third needs to be re-written every time that FOLIO is upgraded from one flower to another - this is how I do that:

#!/usr/bin/perl

$post = `curl -i -s -X POST -H 'Content-type: application/json' -H 'X-Okapi-Tenant: fs[in our case this is an 8-digit long number]' -d '{"username": "myUsername", "password": "myPassword"}' https://okapi-drew.folio.ebsco.com/authn/login`;
@parts = split(/\n/,$post);
foreach $part (@parts) {
    if ($part =~ /^x-okapi-token:/) {
        $xOkapiToken = "X-Okapi-Token: " . substr($part,15);
        $xOkapiToken =~ s/^M//g; $note2self = "*** that looks like ^M but it is not - it is Ctrl+V Ctrl+M ***";
    }
}

open(wH,">/opt/folio/config/headers"); 
print wH qq[-H 'Content-type: application/json' -H 'X-Okapi-Tenant: fs[in our case this is an 8-digit long number]' -H '$xOkapiToken']; 
close(wH);

"Within the Poppy and Quesnelia releases, the current token regime will be deprecated, and be fully replaced by the new RTR-based approach in Sunflower. In the Sunflower release, legacy, non-expiring tokens will no longer be supported." ~ https://folio-org.atlassian.net/wiki/spaces/FOLIJET/pages/1396980/Refresh+Token+Rotation+RTR 


  • No labels
Write a comment…