[Koha-devel] Koha rest api error

Esharat Mia esharat at esharat.me
Tue Mar 7 09:59:17 CET 2023


Dear All,

Hope this email finds you well. I am facing a error koha rest api , I explained below -

I use the below code base for the koha rest api . When I check the bywater koha demo site's rest api, it's working fine but When I checked my demo koha site, getting authentication error(401)

I entered the correct client id and secret ssl certificate installed correctly. My api worked properly using the chrome RESTer tool. Thanks in advance .



import requests

import json

import os

from requests.structures import CaseInsensitiveDict

import http.client

conn = http.client.HTTPSConnection("http://123.49.46.157:8080/")



#from dotenv import load_dotenv



#load_dotenv()

data = {

"client_id": "e877bce0-78bc-4d39-a0c1-2df7fccb1397",

"client_secret": "461cda1a-665d-4d24-a0e0-dace5f83a1f4",

"grant_type": "client_credentials",



}



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



credentials = response.json()

print(credentials)

access_token = credentials['access_token']

print("Access_token: ",access_token)

#auth2 = CaseInsensitiveDict()

auth2={"content-type":"application/json","authorization": f"Bearer {access_token}"}



print(auth2)

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

)



print(response)



Regrads,

Esharat Mia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20230307/21e160f2/attachment.htm>


More information about the Koha-devel mailing list