Why So Confusing? Writing a python script for Nextcloud Talk

I want to write a Python program that sends a message to someone within the Nextcloud Talk application. This is all I want to do.
But the documentation is so complicated that I couldn’t figure out where to start.

I don’t want to write a bot, or a complex application, just a simple script, that’s all.
But in the documentation, assumes that we know everything and talks directly about writing bots etc.
Dude, I just want to write a python script that sends a message to someone within the Nextcloud Talk application and I definitely can’t even figure out where to start.

Actually, if this code works, it will ok, but it gives an error from the first line, and Nextcloud don’t have a simple document explaining how to get the damn token.

.

import requests

def send_message(base_url, username, password, conversation_id, message):
    # Authenticate to get the access token
    auth_url = f"{base_url}/ocs/v2.php/apps/spreed/api/v1/signin"
    auth_data = {"username": username, "password": password}
    auth_response = requests.post(auth_url, data=auth_data)
    auth_response.raise_for_status()
    access_token = auth_response.json()["ocs"]["data"]["token"]

    # Send the message
    send_message_url = f"{base_url}/ocs/v2.php/apps/spreed/api/v1/chat/{conversation_id}/message"
    headers = {"Authorization": f"Bearer {access_token}"}
    message_data = {"message": message}
    send_message_response = requests.post(send_message_url, headers=headers, data=message_data)
    send_message_response.raise_for_status()

    print("Message sent successfully.")

if __name__ == "__main__":
    # Replace these values with your Nextcloud instance details and message content
    nextcloud_base_url = "https://your-nextcloud-instance.com"
    nextcloud_username = "your_username"
    nextcloud_password = "your_password"
    conversation_id = "conversation_id_here"  # Replace with the actual conversation ID
    message_content = "Hello, this is a test message."

    send_message(nextcloud_base_url, nextcloud_username, nextcloud_password, conversation_id, message_content)

.

And this is the error I got :

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://my-nc-instance.com/ocs/v2.php/apps/spreed/api/v1/signin

.
Can someone please tell me how to make the following code work, because from the looks of it and according to the documentation, it should actually work.

But since Nextcloud don’t have a document explaining such a simple process, I can’t find the simple answer I’m looking for.

Thak you.

Did you have a look at this?

https://docs.nextcloud.com/server/stable/developer_manual/client_apis/LoginFlow/index.html#login-flow-v2

use the search - many issues have been discussed already! e.g. take a look at this post: