<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>A new request with request id 11819 has been created by koha-devel-request@lists.koha-community.org. Short info on the request is : <br><br>Title : Koha-devel Digest, Vol 196, Issue 11<br>Category : <br>Description : <div>Send Koha-devel mailing list submissions to<br>    koha-devel@lists.koha-community.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>    https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>or, via email, send a message with subject or body 'help' to<br>    koha-devel-request@lists.koha-community.org<br><br>You can reach the person managing the list at<br>    koha-devel-owner@lists.koha-community.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Koha-devel digest..."<br><br><br>Today's Topics:<br><br>   1. REST API integration issues . (Esharat Mia)<br>   2. Re: REST API integration issues . (Jonathan Druart)<br>   3. Re: REST API integration issues . (Esharat Mia)<br>   4. Re: REST API integration issues . (Eric Phetteplace)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Tue, 15 Mar 2022 22:10:47 +0600<br>From: Esharat Mia <esharat@esharat.me><br>To: "koha-devel" <koha-devel@lists.koha-community.org><br>Subject: [Koha-devel] REST API integration issues .<br>Message-ID:<br>    <17f8e58a22a.103fb1bce614583.8300357358722989196@esharat.me><br>Content-Type: text/plain; charset="utf-8"<br><br>Dear All,<br><br><br><br>Here is my python code for testing REST API -<br><br><br><br>import requests<br><br>import json<br><br>data = {<br><br>"client_id": "52ba706f-902c-4208-b28d-c05df607f3c4",<br><br>"client_secret": "de1c0400-ec02-4143-972e-752931968aed",<br><br>"grant_type": "client_credentials",<br><br><br><br>}<br><br>headers = {<br><br>'Content_type': 'application/x-www-form-urlencoded'<br><br>}<br><br>response = requests.post("http://123.49.46.157:8080/api/v1/oauth/token", data=data, headers=headers)<br><br><br><br>credentials = response.json()<br><br>print(credentials)<br><br>access_token = credentials['access_token']<br><br>print("Access_token: ",access_token)<br><br>auth2 = {<br><br>'Authorization': 'Bearer' +access_token<br><br>}<br><br>response= requests.get("http://123.49.46.157:8080/api/v1/patrons", headers=auth2<br><br>)<br><br><br><br>print(response)<br><br><br><br><br><br>When I run this code , I get access_token . Then I use this access token  and try retrieve data. But getting authentication failure or response code 401 . My output below - <br><br><br><br><br><br> (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py<br><br> <br><br>{'access_token': 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v', 'expires_in': 3600, 'token_type': 'Bearer'}<br><br><br><br>Access_token:  MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v<br><br><br><br><Response [401]><br><br><br><br>Thanks in advance .<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220315/8de32b8c/attachment-0001.htm><br><br>------------------------------<br><br>Message: 2<br>Date: Tue, 15 Mar 2022 17:48:33 +0100<br>From: Jonathan Druart <jonathan.druart@bugs.koha-community.org><br>To: Esharat Mia <esharat@esharat.me><br>Cc: koha-devel <koha-devel@lists.koha-community.org><br>Subject: Re: [Koha-devel] REST API integration issues .<br>Message-ID:<br>    <CAJzKNY76bQsfV_SvMa+EdLAon3Lf8tHY3NBeDEA8BOrDdg3j5g@mail.gmail.com><br>Content-Type: text/plain; charset="UTF-8"<br><br>'Authorization': 'Bearer' +access_token<br><br>Add a space after "Bearer"<br><br>'Authorization': 'Bearer ' +access_token<br><br>Le mar. 15 mars 2022 à 17:10, Esharat Mia <esharat@esharat.me> a écrit :<br>><br>><br>> Dear All,<br>><br>> Here is my python code for testing REST API -<br>><br>> import requests<br>> import json<br>> data = {<br>> "client_id": "52ba706f-902c-4208-b28d-c05df607f3c4",<br>> "client_secret": "de1c0400-ec02-4143-972e-752931968aed",<br>> "grant_type": "client_credentials",<br>><br>> }<br>> headers = {<br>> 'Content_type': 'application/x-www-form-urlencoded'<br>> }<br>> response = requests.post("http://localhost:8080/api/v1/oauth/token", data=data, headers=headers)<br>><br>> credentials = response.json()<br>> print(credentials)<br>> access_token = credentials['access_token']<br>> print("Access_token: ",access_token)<br>> auth2 = {<br>> 'Authorization': 'Bearer' +access_token<br>> }<br>> response= requests.get("http://localhost:8080/api/v1/patrons", headers=auth2<br>> )<br>><br>> print(response)<br>><br>> When I run this code , I get access_token . Then I use this access token  and try retrieve data. But getting authentication failure or response code 401 . My output below -<br>><br>><br>>  (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py<br>><br>> {'access_token': 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v', 'expires_in': 3600, 'token_type': 'Bearer'}<br>><br>> Access_token:  MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v<br>><br>> <Response [401]><br>><br>> Thanks in advance .<br>><br>><br>> _______________________________________________<br>> Koha-devel mailing list<br>> Koha-devel@lists.koha-community.org<br>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>> website : https://www.koha-community.org/<br>> git : https://git.koha-community.org/<br>> bugs : https://bugs.koha-community.org/<br><br><br>------------------------------<br><br>Message: 3<br>Date: Tue, 15 Mar 2022 23:34:01 +0600<br>From: Esharat Mia <esharat@esharat.me><br>To: "Jonathan Druart" <jonathan.druart@bugs.koha-community.org><br>Cc: "koha-devel" <koha-devel@lists.koha-community.org><br>Subject: Re: [Koha-devel] REST API integration issues .<br>Message-ID: <17f8ea4d705.e8332deb632093.801320023024818726@esharat.me><br>Content-Type: text/plain; charset="utf-8"<br><br>Thanks for your response . I add space after Bearer but same error. response code 401.<br><br><br><br><br><br><br><br><br><br><br>---- On Tue, 15 Mar 2022 22:48:33 +0600 Jonathan Druart <jonathan.druart@bugs.koha-community.org> wrote ----<br><br><br><br>'Authorization': 'Bearer' +access_token <br> <br>Add a space after "Bearer" <br> <br>'Authorization': 'Bearer ' +access_token <br> <br>Le mar. 15 mars 2022 à 17:10, Esharat Mia <mailto:esharat@esharat.me> a écrit : <br>> <br>> <br>> Dear All, <br>> <br>> Here is my python code for testing REST API - <br>> <br>> import requests <br>> import json <br>> data = { <br>> "client_id": "52ba706f-902c-4208-b28d-c05df607f3c4", <br>> "client_secret": "de1c0400-ec02-4143-972e-752931968aed", <br>> "grant_type": "client_credentials", <br>> <br>> } <br>> headers = { <br>> 'Content_type': 'application/x-www-form-urlencoded' <br>> } <br>> response = requests.post("http://localhost:8080/api/v1/oauth/token", data=data, headers=headers) <br>> <br>> credentials = response.json() <br>> print(credentials) <br>> access_token = credentials['access_token'] <br>> print("Access_token: ",access_token) <br>> auth2 = { <br>> 'Authorization': 'Bearer' +access_token <br>> } <br>> response= requests.get("http://localhost:8080/api/v1/patrons", headers=auth2 <br>> ) <br>> <br>> print(response) <br>> <br>> When I run this code , I get access_token . Then I use this access token  and try retrieve data. But getting authentication failure or response code 401 . My output below - <br>> <br>> <br>>  (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py <br>> <br>> {'access_token': 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v', 'expires_in': 3600, 'token_type': 'Bearer'} <br>> <br>> Access_token:  MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v <br>> <br>> <Response [401]> <br>> <br>> Thanks in advance . <br>> <br>> <br>> _______________________________________________ <br>> Koha-devel mailing list <br>> mailto:Koha-devel@lists.koha-community.org <br>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel <br>> website : https://www.koha-community.org/ <br>> git : https://git.koha-community.org/ <br>> bugs : https://bugs.koha-community.org/<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220315/09033cbd/attachment-0001.htm><br><br>------------------------------<br><br>Message: 4<br>Date: Tue, 15 Mar 2022 11:20:06 -0700<br>From: Eric Phetteplace <ephetteplace@cca.edu><br>To: Esharat Mia <esharat@esharat.me><br>Cc: Jonathan Druart <jonathan.druart@bugs.koha-community.org>,<br>    koha-devel <koha-devel@lists.koha-community.org><br>Subject: Re: [Koha-devel] REST API integration issues .<br>Message-ID:<br>    <CACSkZcY40KPOxCA3Am==sdQPFuj8tNXtoh8PJu+YHZw2Vu5C_g@mail.gmail.com><br>Content-Type: text/plain; charset="utf-8"<br><br>Could you share your complete updated code again? And it would also be<br>helpful to see more information about the response. You could print<br>response.headers and response.text as well as response.status_code.<br><br>I thought the space after Bearer would fix it, so if your syntax is right<br>now, my next guess is that the patron you configured this OAuth client for<br>does not have permission to access patron data. Make sure to use a<br>librarian account with "Set permissions" when you create the client (you<br>can give them "Access to all librarian functions" if you're practicing<br>locally).<br><br>Best,<br><br>ERIC PHETTEPLACE Systems Librarian, Libraries (he/him)<br><br>ephetteplace@cca.edu | o 510.594.3660 (cca)<br><br>5212 Broadway | Oakland, CA | 94618<br><br>CCA is situated on the traditional unceded lands of the Ohlone peoples.<br><br>Black-owned bookstores in Oakland: Ashay by the Bay<br><https://ashaybythebay.com/>, Marcus Books<br><https://www.facebook.com/marcus.books/><br><br>:(){ :|: & };:<br><br><br>On Tue, Mar 15, 2022 at 10:34 AM Esharat Mia <esharat@esharat.me> wrote:<br><br>> Thanks for your response . I add space after Bearer but same error.<br>> response code 401.<br>><br>><br>><br>><br>> ---- On Tue, 15 Mar 2022 22:48:33 +0600 *Jonathan Druart<br>> <jonathan.druart@bugs.koha-community.org<br>> <jonathan.druart@bugs.koha-community.org>>* wrote ----<br>><br>> 'Authorization': 'Bearer' +access_token<br>><br>> Add a space after "Bearer"<br>><br>> 'Authorization': 'Bearer ' +access_token<br>><br>> Le mar. 15 mars 2022 à 17:10, Esharat Mia <esharat@esharat.me> a écrit :<br>> ><br>> ><br>> > Dear All,<br>> ><br>> > Here is my python code for testing REST API -<br>> ><br>> > import requests<br>> > import json<br>> > data = {<br>> > "client_id": "52ba706f-902c-4208-b28d-c05df607f3c4",<br>> > "client_secret": "de1c0400-ec02-4143-972e-752931968aed",<br>> > "grant_type": "client_credentials",<br>> ><br>> > }<br>> > headers = {<br>> > 'Content_type': 'application/x-www-form-urlencoded'<br>> > }<br>> > response = requests.post("http://localhost:8080/api/v1/oauth/token",<br>> data=data, headers=headers)<br>> ><br>> > credentials = response.json()<br>> > print(credentials)<br>> > access_token = credentials['access_token']<br>> > print("Access_token: ",access_token)<br>> > auth2 = {<br>> > 'Authorization': 'Bearer' +access_token<br>> > }<br>> > response= requests.get("http://localhost:8080/api/v1/patrons",<br>> headers=auth2<br>> > )<br>> ><br>> > print(response)<br>> ><br>> > When I run this code , I get access_token . Then I use this access token<br>> and try retrieve data. But getting authentication failure or response code<br>> 401 . My output below -<br>> ><br>> ><br>> > (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py<br>> ><br>> > {'access_token':<br>> 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v',<br>> 'expires_in': 3600, 'token_type': 'Bearer'}<br>> ><br>> > Access_token:<br>> MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v<br>><br>> ><br>> > <Response [401]><br>> ><br>> > Thanks in advance .<br>> ><br>> ><br>> > _______________________________________________<br>> > Koha-devel mailing list<br>> > Koha-devel@lists.koha-community.org<br>> > https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>> > website : https://www.koha-community.org/<br>> > git : https://git.koha-community.org/<br>> > bugs : https://bugs.koha-community.org/<br>><br>><br>><br>> _______________________________________________<br>> Koha-devel mailing list<br>> Koha-devel@lists.koha-community.org<br>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>> website : https://www.koha-community.org/<br>> git : https://git.koha-community.org/<br>> bugs : https://bugs.koha-community.org/<br>><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220315/ff361cef/attachment.htm><br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>Koha-devel mailing list<br>Koha-devel@lists.koha-community.org<br>https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>website : https://www.koha-community.org/<br>git : https://git.koha-community.org/<br>bugs : https://bugs.koha-community.org/<br><br><br>------------------------------<br><br>End of Koha-devel Digest, Vol 196, Issue 11<br>*******************************************<br></div><br><br>NOTE: You are receiving this mail because, the Requester/Technician wanted you to get notified on this request creation.<br></body></html>