[Bug 43592] New: Google Books API quota error
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Bug ID: 43592 Summary: Google Books API quota error Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: OPAC Assignee: oleonard@myacpl.org Reporter: amitddng135@gmail.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- Requesting Google Books data via [https://www.googleapis.com/books/v1/volumes?q=9781492180746](https://www.googleapis.com/books/v1/volumes?q=9781492180746) fails with a quota error (HTTP 429 Too Many Requests) because Google requires an API key for reliable, unthrottled requests. Furthermore, querying raw numbers without the isbn: qualifier fails to restrict results precisely to ISBN matches. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|oleonard@myacpl.org |amitddng135@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 --- Comment #1 from Amit Gupta <amitddng135@gmail.com> --- Created attachment 206499 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206499&action=edit Error Google book -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Sponsorship status|--- |Sponsored Comma delimited| |Amit Gupta list of Sponsors| |(amit.gupta@informaticsglob | |al.ai) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Google Books API quota |Google Books OPAC |error |suggestion autofill fails | |with quota error due to | |missing API key and query | |format -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 --- Comment #2 from Amit Gupta <amitddng135@gmail.com> --- Created attachment 206500 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206500&action=edit Bug 43592: Google Books OPAC suggestion autofill fails with quota error due to missing API key and query format Querying the Google Books API without an API key using the endpoint format 'https://www.googleapis.com/books/v1/volumes?q=<isbn>' triggers 429 quota errors because unauthenticated IP-based requests are heavily throttled. Additionally, omitting the 'isbn:' search qualifier can fail to return exact ISBN matches. This patch updates autofill.js 1. Explicitly prepend 'isbn:' to the query string (q=isbn:<clean_isbn>). 2. Pass the 'GoogleBooksApiKey' system preference to append '&key=<apiKey>'. 3. Clean and sanitize ISBN input values. Test Plan: 1. Log in to the Koha Staff Interface as an administrator. 2. Go to Administration -> System preferences and enable OPACSuggestionAutoFill. 3. Log in to the OPAC and go to the Purchase Suggestion page (opac-suggestions.pl?op=add). 4. Enter a valid ISBN (e.g., 9781492180746) in the ISBN field and click "Search Google Books". 5. No result populates 6. Apply the patch. 7. Go to Administration -> System preferences in the Staff Interface. 8. Search for GoogleBooksApiKey and enter a valid Google Books API key. 9. Return to the OPAC Purchase Suggestion page, enter the ISBN, and click "Search Google Books". 10. Verify that the book details (Title, Author, Publisher) populate correctly into the form. Added new System preference: GoogleBooksApiKey -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 --- Comment #3 from Amit Gupta <amitddng135@gmail.com> --- Generate Google API key: 1.Open the Google Cloud Console: Google Cloud Console – Credentials 2. Select your Google Cloud Project. You can create a new project if you don't already have one. 3. Go to APIs & Services → Library. 4. Search for Books API and enable it. 5. Go to APIs & Services → Credentials. Click Create Credentials → API key. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amit.gupta@informaticsgloba | |l.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 --- Comment #4 from Amit Gupta <amitddng135@gmail.com> --- Created attachment 206514 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206514&action=edit Bug 43592: Add GoogleBooksApiKey system preference Add a new system preference GoogleBooksApiKey used to fetch book data from Google Books. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #206514|0 |1 is obsolete| | --- Comment #5 from Amit Gupta <amitddng135@gmail.com> --- Created attachment 206515 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206515&action=edit Bug 43592: Add GoogleBooksApiKey system preference Add a new system preference GoogleBooksApiKey used to fetch book data from Google Books. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Daniel Aguete <daniel.aguete@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |daniel.aguete@xercode.es --- Comment #6 from Daniel Aguete <daniel.aguete@xercode.es> --- Tested on koha-testing-docker (main). Not signing off, as I couldn't complete the test plan: - Without the patch: volumes?q=<isbn> returns 429, as described. - With the patch: the request is built correctly (q=isbn:<isbn>&key=<key>), and the key is valid (a fake key returns 400). - However, the Google Books API returns 503 "backendFailed" for almost every request over several days, so I couldn't verify that the form gets populated (step 10). Others report the same issue: https://issuetracker.google.com/issues/569300353 Amit, does the API work for you at the moment? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 --- Comment #7 from Amit Gupta <amitddng135@gmail.com> --- Hi Daniel, The API isn't working at the moment with ISBN I tried another API for example, and it's working. GET https://www.googleapis.com/books/v1/volumes?q=intitle:The+Mom+Test+inauthor:Fitzpatrick&key=YOUR_API_KEY -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Daniel Aguete <daniel.aguete@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off --- Comment #8 from Daniel Aguete <daniel.aguete@xercode.es> --- Tested on koha-testing-docker (main). Since isbn: queries currently fail on Google's side (503), I temporarily changed the query to intitle:The+Mom+Test+inauthor:Fitzpatrick, as Amit suggested (not part of the patch, reverted before signing off): - Without the patch, requests without a key return 429. - With the patch and GoogleBooksApiKey set, the key is sent and the form is populated correctly (title, author, publisher). Note (unrelated to this patch): with CSP enabled, the OPAC autofill is blocked (connect-src for googleapis.com, and an EvalError due to 'unsafe-eval' in autofill.js). I tested with the OPAC CSP in report-only mode. Signing off. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 Daniel Aguete <daniel.aguete@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #206500|0 |1 is obsolete| | Attachment #206515|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 --- Comment #9 from Daniel Aguete <daniel.aguete@xercode.es> --- Created attachment 208952 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208952&action=edit Bug 43592: Google Books OPAC suggestion autofill fails with quota error due to missing API key and query format Querying the Google Books API without an API key using the endpoint format 'https://www.googleapis.com/books/v1/volumes?q=<isbn>' triggers 429 quota errors because unauthenticated IP-based requests are heavily throttled. Additionally, omitting the 'isbn:' search qualifier can fail to return exact ISBN matches. This patch updates autofill.js 1. Explicitly prepend 'isbn:' to the query string (q=isbn:<clean_isbn>). 2. Pass the 'GoogleBooksApiKey' system preference to append '&key=<apiKey>'. 3. Clean and sanitize ISBN input values. Test Plan: 1. Log in to the Koha Staff Interface as an administrator. 2. Go to Administration -> System preferences and enable OPACSuggestionAutoFill. 3. Log in to the OPAC and go to the Purchase Suggestion page (opac-suggestions.pl?op=add). 4. Enter a valid ISBN (e.g., 9781492180746) in the ISBN field and click "Search Google Books". 5. No result populates 6. Apply the patch. 7. Go to Administration -> System preferences in the Staff Interface. 8. Search for GoogleBooksApiKey and enter a valid Google Books API key. 9. Return to the OPAC Purchase Suggestion page, enter the ISBN, and click "Search Google Books". 10. Verify that the book details (Title, Author, Publisher) populate correctly into the form. Signed-off-by: Daniel Aguete <daniel.aguete@xercode.es> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43592 --- Comment #10 from Daniel Aguete <daniel.aguete@xercode.es> --- Created attachment 208953 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208953&action=edit Bug 43592: Add GoogleBooksApiKey system preference Add a new system preference GoogleBooksApiKey used to fetch book data from Google Books. Signed-off-by: Daniel Aguete <daniel.aguete@xercode.es> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org