[Koha-devel] Session Token fo Login into Koha

Muhammad Uzair uzair.metro at gmail.com
Tue Mar 28 08:27:53 CEST 2023


Hey!
I am using the following code to retrieve the session code from Koha using
Koha RestAPI.

import requests
import base64

domain = 'http://my-domain.com'
username = 'user'
password = 'password'
api_key = 'my-api-key'
client_id = 'id'

url = f'{domain}/api/v1/auth/token'
auth_header_value =
base64.b64encode(f'{username}:{password}'.encode()).decode()

headers = {
    'Authorization': f'Basic {auth_header_value}',
    'X-API-Key': api_key
}

response = requests.post(url, headers=headers)

if response.status_code == 200:
    access_token = response.text
    print(f"Access token: {access_token}")
else:
    print(f"Error: {response.status_code} {response.reason}")

I am supposed to get a session token with response code 200. But I am
getting an error 404 i.e. default response. I have done the code in perl
but getting the same response.

Kindly help me to solve this issue as it is my university project.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20230327/d8894dc8/attachment.htm>


More information about the Koha-devel mailing list