Tuesday 5 January 2021

React Native - Use cookies to authenticate in WebView

So I've been provided a couple of API's for a React Native application. One endpoint is for authentication and it returns a cookie which allows access to other API's.

The cookie has the following structure:

{"auth":"ok","instance":"private","cookies":{"SSOsess":"300|c6dc6d70vfvbf0891004364665f24b77","RTBk":"300|451706342c67a37dfe5dede0b5d22469","ph03RPNCiscoASA":"application.api.urlweb.com","ph04RPNCiscoASA":"application.client.urlweb.com"}}

The are some WebView's inside the React Native application that access some restricted parts of a website that uses some of the API's initially provided.

How can I send the cookie to the WebView and in what format? I know React Native has some attributes that could be used to inject cookies into the WebView such as injectedJavaScript or injectedJavaScriptBeforeContentLoaded but what exactly should those attributes contain? In what format the cookie above should be modified to be passed in the WebView?

<WebView source=
               style=
               injectedJavaScriptBeforeContentLoaded={???}
/>


from React Native - Use cookies to authenticate in WebView

No comments:

Post a Comment