Authenticate user in a WebView

Is there a way to authenticate a user that is already authenticated in either StoreFront Api or Customer Account API, to open a webpage and keep their authentication?

I saw some mentions about passing “X-Shopify-Customer-Access-Token” in the headers, but that does not seem to work anymore.

Our use case is not for the checkout, is to open a specific web page that requires the user to be logged in.

Thanks in advance.

1 Like

There’s nothing built-in, but if you’re using new customer accounts (and the Customer Account API), you can build something yourself that does it. You need to ensure the cookies are shared between the WebView that shows the login and the WebView that shows the other page where you want the user to be authenticated. Normally this is done automatically if using SFSafariViewController, otherwise you’ll have to do it manually.

After that, any attempt to authenticate the user should detect that the user is authenticated and skip asking them for their credentials. All you need to do then is open the page you want the user authenticated on, and trigger an authorization request. Optionally, you can use the prompt=none parameter defined here to fallback to a guest session when the user’s session is not active (it either authenticates them without user interaction or navigates back to the client).

If the page you want to show is on the online store, you can use this URL to trigger an authorization request from it.

1 Like