OJS 3.1. Use of the API key

Hi PKP forum. :smiley:

I’m frontender working with the migration of the Royal Danish Library’s OJS from 2.4 to 3.1.
Many of our hosted journals are looking forward to use the new build-in API, so I’m trying to figuring out how to make it work.

When I’m logged in as OJS Admin or Journal Admin I can access the API url directly in the browser like this:

http://our-local-test-instance.dk/index.php/journalpath/api/v1/issues

which return the expected json. :ok_hand:

When I generate an API key and try to use that key like in this Swagger doc (API Keys) in a browser not logged in like this:

http://our-local-test-instance.dk/index.php/journalpath/api/v1/issues?api_key=api.key.generated.for.user

The server returns a 404. :confused:

I have tried with both enabled and disabled external applications with the API key with the same result.

Is this expected behaviuor, and do I need to use cURL to make it work?

1 Like

Hi Nielsgamborg,

The API Key should be specified in the url using “apiToken” not “api_key”.

(http://our-local-test-instance.dk/index.php/journalpath/api/v1/issues?apiToken=api.key.generated.for.user)

Please give a try and let me know if it works.

// Kassim

1 Like

Hi kaschioudi.

Thanks a lot for your for the help. Works like a charm. :ok_hand:

Wish all bug fixing was that easy. :wink:

/Niels

Hi everybody,

I have a similar problem as nielsgamborg
I have an OJS installation (v 3.1.0.0) and when logged in I can call the REST service and get the issues list.
But if not logged in and using an API key I only get a 404 response.

I’m quite sure that I use the right URL, but perhaps I’m doing somethging wrong with the key.
I set the key in the OJS’s config.inc.php setting i.e.

api_key_secret = "lkjx$%fbg18594hjadslgikjbgiuh"

(I also tried simpler and shorter values)
and in my request

http://myserver.address/index.php/myjournal/api/v1/issues?apiToken=lkjx$%fbg18594hjadslgikjbgiuh

@nielsgamborg: You wrote

I have tried with both enabled and disabled external applications with the API key with the same result.

What did you mean with that? How can I resp. do I have to “enable external applications” in OJS?

Hoping for some hint

//ul

1 Like

apiToken is not same api_key_secret in config file. apiToken can be found at Profile > API Key