Long Lived access token using Websocket API or REST API

Hello
I need to control my Homeassistant from a third party app. For that I require Long lived access token . I know it can be taken from the UI. But i will be using Headless Gateway and wont be using any UI. What all are the best methods to control Homeassistant Gateway the above mentioned way and How to get the Long lived access token through API.
I tried to get Long lived access token with Websocket and REST APIs but iam getting invalid auth error. Do any one can tell me the exact steps to retrieve Long lived access Token from Homeassistant through REST API or Websocket API

Hello Calixto,
I have the same issue and looking for a solution.
Have you found any solution in meantime?

I mean you need an access token to talk to either of those so kind of a chicken and egg problem. I’m not sure how you plan to use HA without any UI at all, there are now many integrations which can only be set up from the UI. Did you go through the list of integrations you need to use and confirm that all of them can be set up without using the UI? Even then there seems to be integrations which become ui-configurable only every release so you may have issues in the future.

I would guess your best route here is to make an addon and then use that as a proxy to HAs API. Since all addons get an access token they can use to make calls to supervisor and HA’s APIs. But really I think you’re going to get stuck without any UI access, HA isn’t really designed for that.

Hello,
yes I understand your points.
But my plan is to access my Home Assistant via Rest-API from a standalone client. At initial configuration I need a long live token for Rest-API Authentification. It will more convinient for me to get the long live token via websocket and Username and password.