LP#169625: Support script for working with OverDrive API
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 8 Jun 2017 18:09:04 +0000 (11:09 -0700)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 4 Mar 2021 15:28:29 +0000 (10:28 -0500)
commit2337f282aeb7717ca0f70272a42ab33b7e045e93
treed93fe6e24d66a4cc92c2a22a60b896862b741b50
parentcea475f620ffc5f0539f46e3c3671a0f9db23e7d
LP#169625: Support script for working with OverDrive API

Adds a script, overdrive-api-checker.pl, for testing the
OverDrive API from the command line.

USAGE:
    Open-ILS/src/support-scripts/overdrive-api-checker.pl --get-token --key <client-key> --secret <client-secret>
    Open-ILS/src/support-scripts/overdrive-api-checker.pl --account <account_id> --token <basic_token> [ --endpoint https://api.overdrive.com/v1/libraries/1234 [ --content <content> ] ]
    Open-ILS/src/support-scripts/overdrive-api-checker.pl --account <account_id> --token <basic_token> --oauth-only
    Open-ILS/src/support-scripts/overdrive-api-checker.pl --account <account_id> --token <basic_token> --patron-auth [ --endpoint https://oauth-patron.overdrive.com/patrontoken ] --barcode <barcode> [ --password <password> ] --websiteid <websiteid> --authorizationname <authorizationname>

OPTIONS:
    --get-token
        Generate OverDrive API basic token.
    --key
        Client key supplied by OverDrive.  Required with --get-token.
    --secret
        Client secret supplied by OverDrive.  Required with --get-token.
    --token
        Your OverDrive API basic token (clientKey:clientSecret, Base64-encoded).
        Required unless using --get-token.
    --account
        Your OverDrive API account ID (e.g. 1234).  Not required for generating
        a basic token; required for everything else.
    --oauth-endpoint
        OverDrive API endpoint for OAuth token requests.
        Default: https://oauth.overdrive.com/token.
    --endpoint
        OverDrive API endpoint that you wish to test.
        Default: https://api.overdrive.com/v1/libraries/<account>
    --content
        JSON content of main API request.  Required only if you have specified
        an endpoint that expects JSON message content.
    --oauth-only
        Only request an OAuth token; do not attempt further API requests.
    --patron-auth
        Submit a patron authentication request.
    --barcode
        Patron barcode.  Required with --patron-auth.
    --password
        Patron password.  Required with --patron-auth if your library requires
        password for patron authentication.
    --websiteid
        Website ID supplied by OverDrive.  Required with --patron-auth.
    --authorizationname
        ILS name supplied by OverDrive.  Required with --patron-auth.
    --verbose
        Print full HTTP requests and responses.
    --help
        Print this help message.

EXAMPLES:

    To generate your basic token, given a client key and client secret supplied
    by OverDrive:

    Open-ILS/src/support-scripts/overdrive-api-checker.pl --get-token --key <client-key> --secret <client-secret>

    To send a basic API request (this is useful for validating your client
    credentials and determining whether the OverDrive API is currently
    available):

    Open-ILS/src/support-scripts/overdrive-api-checker.pl --account <account_id> --token <basic_token>

    To send a request to a specific API endpoint:

    Open-ILS/src/support-scripts/overdrive-api-checker.pl --account <account_id> --token <basic_token>
    --endpoint <endpoint> --content <content>

    To test OverDrive API authentication for a specific patron:

    Open-ILS/src/support-scripts/overdrive-api-checker.pl --account <account_id> --token <basic_token>
    --patron-auth --barcode <barcode> --password <password>
    --websiteid <websiteid> --authorizationname <authorizationname>

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Martha Driscoll <driscoll@noblenet.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/support-scripts/overdrive-api-checker.pl [new file with mode: 0755]