A new request with request id 11819 has been created by koha-devel-request@lists.koha-community.org. Short info on the request is :

Title : Koha-devel Digest, Vol 196, Issue 11
Category :
Description :
Send Koha-devel mailing list submissions to
    koha-devel@lists.koha-community.org

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
or, via email, send a message with subject or body 'help' to
    koha-devel-request@lists.koha-community.org

You can reach the person managing the list at
    koha-devel-owner@lists.koha-community.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Koha-devel digest..."


Today's Topics:

1. REST API integration issues . (Esharat Mia)
2. Re: REST API integration issues . (Jonathan Druart)
3. Re: REST API integration issues . (Esharat Mia)
4. Re: REST API integration issues . (Eric Phetteplace)


----------------------------------------------------------------------

Message: 1
Date: Tue, 15 Mar 2022 22:10:47 +0600
From: Esharat Mia <esharat@esharat.me>
To: "koha-devel" <koha-devel@lists.koha-community.org>
Subject: [Koha-devel] REST API integration issues .
Message-ID:
    <17f8e58a22a.103fb1bce614583.8300357358722989196@esharat.me>
Content-Type: text/plain; charset="utf-8"

Dear All,



Here is my python code for testing REST API -



import requests

import json

data = {

"client_id": "52ba706f-902c-4208-b28d-c05df607f3c4",

"client_secret": "de1c0400-ec02-4143-972e-752931968aed",

"grant_type": "client_credentials",



}

headers = {

'Content_type': 'application/x-www-form-urlencoded'

}

response = requests.post("http://123.49.46.157:8080/api/v1/oauth/token", data=data, headers=headers)



credentials = response.json()

print(credentials)

access_token = credentials['access_token']

print("Access_token: ",access_token)

auth2 = {

'Authorization': 'Bearer' +access_token

}

response= requests.get("http://123.49.46.157:8080/api/v1/patrons", headers=auth2

)



print(response)





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 - 





 (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py



{'access_token': 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v', 'expires_in': 3600, 'token_type': 'Bearer'}



Access_token:  MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v



<Response [401]>



Thanks in advance .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220315/8de32b8c/attachment-0001.htm>

------------------------------

Message: 2
Date: Tue, 15 Mar 2022 17:48:33 +0100
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
To: Esharat Mia <esharat@esharat.me>
Cc: koha-devel <koha-devel@lists.koha-community.org>
Subject: Re: [Koha-devel] REST API integration issues .
Message-ID:
    <CAJzKNY76bQsfV_SvMa+EdLAon3Lf8tHY3NBeDEA8BOrDdg3j5g@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

'Authorization': 'Bearer' +access_token

Add a space after "Bearer"

'Authorization': 'Bearer ' +access_token

Le mar. 15 mars 2022 à 17:10, Esharat Mia <esharat@esharat.me> a écrit :
>
>
> Dear All,
>
> Here is my python code for testing REST API -
>
> import requests
> import json
> data = {
> "client_id": "52ba706f-902c-4208-b28d-c05df607f3c4",
> "client_secret": "de1c0400-ec02-4143-972e-752931968aed",
> "grant_type": "client_credentials",
>
> }
> headers = {
> 'Content_type': 'application/x-www-form-urlencoded'
> }
> response = requests.post("http://localhost:8080/api/v1/oauth/token", data=data, headers=headers)
>
> credentials = response.json()
> print(credentials)
> access_token = credentials['access_token']
> print("Access_token: ",access_token)
> auth2 = {
> 'Authorization': 'Bearer' +access_token
> }
> response= requests.get("http://localhost:8080/api/v1/patrons", headers=auth2
> )
>
> print(response)
>
> 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 -
>
>
> (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py
>
> {'access_token': 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v', 'expires_in': 3600, 'token_type': 'Bearer'}
>
> Access_token: MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v
>
> <Response [401]>
>
> Thanks in advance .
>
>
> _______________________________________________
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/


------------------------------

Message: 3
Date: Tue, 15 Mar 2022 23:34:01 +0600
From: Esharat Mia <esharat@esharat.me>
To: "Jonathan Druart" <jonathan.druart@bugs.koha-community.org>
Cc: "koha-devel" <koha-devel@lists.koha-community.org>
Subject: Re: [Koha-devel] REST API integration issues .
Message-ID: <17f8ea4d705.e8332deb632093.801320023024818726@esharat.me>
Content-Type: text/plain; charset="utf-8"

Thanks for your response . I add space after Bearer but same error. response code 401.










---- On Tue, 15 Mar 2022 22:48:33 +0600 Jonathan Druart <jonathan.druart@bugs.koha-community.org> wrote ----



'Authorization': 'Bearer' +access_token

Add a space after "Bearer"

'Authorization': 'Bearer ' +access_token

Le mar. 15 mars 2022 à 17:10, Esharat Mia <mailto:esharat@esharat.me> a écrit :
>
>
> Dear All,
>
> Here is my python code for testing REST API -
>
> import requests
> import json
> data = {
> "client_id": "52ba706f-902c-4208-b28d-c05df607f3c4",
> "client_secret": "de1c0400-ec02-4143-972e-752931968aed",
> "grant_type": "client_credentials",
>
> }
> headers = {
> 'Content_type': 'application/x-www-form-urlencoded'
> }
> response = requests.post("http://localhost:8080/api/v1/oauth/token", data=data, headers=headers)
>
> credentials = response.json()
> print(credentials)
> access_token = credentials['access_token']
> print("Access_token: ",access_token)
> auth2 = {
> 'Authorization': 'Bearer' +access_token
> }
> response= requests.get("http://localhost:8080/api/v1/patrons", headers=auth2
> )
>
> print(response)
>
> 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 -
>
>
> (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py
>
> {'access_token': 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v', 'expires_in': 3600, 'token_type': 'Bearer'}
>
> Access_token: MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v
>
> <Response [401]>
>
> Thanks in advance .
>
>
> _______________________________________________
> Koha-devel mailing list
> mailto:Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220315/09033cbd/attachment-0001.htm>

------------------------------

Message: 4
Date: Tue, 15 Mar 2022 11:20:06 -0700
From: Eric Phetteplace <ephetteplace@cca.edu>
To: Esharat Mia <esharat@esharat.me>
Cc: Jonathan Druart <jonathan.druart@bugs.koha-community.org>,
    koha-devel <koha-devel@lists.koha-community.org>
Subject: Re: [Koha-devel] REST API integration issues .
Message-ID:
    <CACSkZcY40KPOxCA3Am==sdQPFuj8tNXtoh8PJu+YHZw2Vu5C_g@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Could you share your complete updated code again? And it would also be
helpful to see more information about the response. You could print
response.headers and response.text as well as response.status_code.

I thought the space after Bearer would fix it, so if your syntax is right
now, my next guess is that the patron you configured this OAuth client for
does not have permission to access patron data. Make sure to use a
librarian account with "Set permissions" when you create the client (you
can give them "Access to all librarian functions" if you're practicing
locally).

Best,

ERIC PHETTEPLACE Systems Librarian, Libraries (he/him)

ephetteplace@cca.edu | o 510.594.3660 (cca)

5212 Broadway | Oakland, CA | 94618

CCA is situated on the traditional unceded lands of the Ohlone peoples.

Black-owned bookstores in Oakland: Ashay by the Bay
<https://ashaybythebay.com/>, Marcus Books
<https://www.facebook.com/marcus.books/>

:(){ :|: & };:


On Tue, Mar 15, 2022 at 10:34 AM Esharat Mia <esharat@esharat.me> wrote:

> Thanks for your response . I add space after Bearer but same error.
> response code 401.
>
>
>
>
> ---- On Tue, 15 Mar 2022 22:48:33 +0600 *Jonathan Druart
> <jonathan.druart@bugs.koha-community.org
> <jonathan.druart@bugs.koha-community.org>>* wrote ----
>
> 'Authorization': 'Bearer' +access_token
>
> Add a space after "Bearer"
>
> 'Authorization': 'Bearer ' +access_token
>
> Le mar. 15 mars 2022 à 17:10, Esharat Mia <esharat@esharat.me> a écrit :
> >
> >
> > Dear All,
> >
> > Here is my python code for testing REST API -
> >
> > import requests
> > import json
> > data = {
> > "client_id": "52ba706f-902c-4208-b28d-c05df607f3c4",
> > "client_secret": "de1c0400-ec02-4143-972e-752931968aed",
> > "grant_type": "client_credentials",
> >
> > }
> > headers = {
> > 'Content_type': 'application/x-www-form-urlencoded'
> > }
> > response = requests.post("http://localhost:8080/api/v1/oauth/token",
> data=data, headers=headers)
> >
> > credentials = response.json()
> > print(credentials)
> > access_token = credentials['access_token']
> > print("Access_token: ",access_token)
> > auth2 = {
> > 'Authorization': 'Bearer' +access_token
> > }
> > response= requests.get("http://localhost:8080/api/v1/patrons",
> headers=auth2
> > )
> >
> > print(response)
> >
> > 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 -
> >
> >
> > (base) esharat@esharat-desktop:~/Desktop/Library$ python3 test.py
> >
> > {'access_token':
> 'MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v',
> 'expires_in': 3600, 'token_type': 'Bearer'}
> >
> > Access_token:
> MTY0NzM2MDQ3Mi00MzgwNzctMC42OTA2NTM5MzA1MDgxODQtM0pTSTcwdUhGcVdzaTlUUnhGcGVDaTFmaVg3Nm9v
>
> >
> > <Response [401]>
> >
> > Thanks in advance .
> >
> >
> > _______________________________________________
> > Koha-devel mailing list
> > Koha-devel@lists.koha-community.org
> > https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> > website : https://www.koha-community.org/
> > git : https://git.koha-community.org/
> > bugs : https://bugs.koha-community.org/
>
>
>
> _______________________________________________
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220315/ff361cef/attachment.htm>

------------------------------

Subject: Digest Footer

_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


------------------------------

End of Koha-devel Digest, Vol 196, Issue 11
*******************************************


NOTE: You are receiving this mail because, the Requester/Technician wanted you to get notified on this request creation.