Customer API Authentification with non-browser environment

I have a server-side application which is non-browser environment and want to call Customer API . How can i get the customer access token without any web widgets?

1 Like

Hi @Ryan_G,

To do this you would first need to create a customer using the “/customer” operation on the LiveChat Accounts API.

This will return a customer access token which you can then use to interact with LiveChat on behalf of a client.

I have question about this reply.
As you mentioned create customer via LiveAccount API will return customer access token. I tested via v3.3{{api_version}}/agent/action/create_customer only return customer_id 1 field only. At the mean time, we do need pass the authorization code to call create customer API too. Which need browser environment as well.

So finalize that, how can we get the access token from Agent Livechat API with non-browser environment and then use the Agent Access token to call customer livechat api.

To use Accounts API you need agent access token (OAuth bearer token), to obtain this token you should force user to do whole OAuth process, including signing in with login/password on html page. The question asked was “How can i get the customer access token without any web widgets?”.
The answer is to 1. simulate programmatically what agent would do on Livechat sign-in html page and parse redirect header with agent access token. You should do that securely (eg. not on mobile side).
2. Or wait for LiveChat to allow using PAT in Accounts API and thus allowing creating customer access token with single http request.

First solution described has limit of 3 sign-in request per 30 seconds.

1 Like

Hello. In case of backend services where it may not be convenient to use Agent grant flow, you can rely on Cookies grant flow described here: Authorizing API calls | LiveChat Platform Docs & API Reference. In simple words it allows you to create and refresh the Customer tokens without the need to have the Agent token first.

Hope it will help with the described issue. If you will have any questions feel free to ask.