Authentication from native mobile app

Hi,

I’m working on a native mobile app (swift) and i would like to build a custom chat interface on top of the customer API.

I’m struggling with the authentication process.
Is there any way to get an access token without the redirecting web process ? Can i just call an endpoint with the client_id/client_secret ?
I can’t find that solution anywhere in the documentation

Thanks for your help

Hello, @baptiste

In your case, there are two ways to get access token

  1. You can follow this process from the beginning to the end:
    https://developers.livechatinc.com/docs/getting-started/authorization/#public-server-side-apps

  2. In the Step 2 of the process above, you can make one redirect
    (modified sample URL: https://accounts.livechatinc.com/?response_type=token&client_id=your_client_id&redirect_uri=your_redirect_uri )

The difference between these two ways is that in the first case you get access_token with the lifespan of 8h and infinite refresh_token to refresh your access for another 8h, etc.
In the second case you get one access_token for 8h and after this period you have to repeat the process all over again.

By the way, if you want to build your own widget, we encourage you to use our Customer SDK

Hope I helped!

Hi @Lukasz_W,

Thanks for your response. However i’m not sure you’ve understood my question :wink:

Second step of the process you’ve mentioned is:

Start with redirecting your user to the following address: https://accounts.livechatinc.com/

That’s exactly what we want to avoid for a native mobile app. We should be able to get an access_token without presenting a webview to the user.

Also Customer API is JS…

Unfortunately, because of the security reasons, there is no way to avoid this process.

If you need more specific info, please contact us at support@livechatinc.com