Search code examples
tokenjwtrequest-headerssfsafariviewcontroller

Set the request Authorization header in SFSafariViewController


I have application that have username and password, so that user logs to the app. Some (less important) functionality is still as web page.

But to be user friendly, it is annoying for user to login again after already logging in.

I am looking at the SFSafariViewController and it looks promising, but I am trying to set the Authorization header when calling the URL. I already know the user token, but it needs to be set as Authorization headers.

So the flow it would be:

User log in inside App -> get token -> set this token as Authorization header -> call my web app url

Is this possible with this controller?


Solution

  • As discussed this what you should do

    When you login from the app you receive a token. Next you should create an extra endpoint for login, say loginWithToken. The format of the same could be something like

    https://example.com/loginWithToken?token=xyz&returnURL=def
    

    From your app you will navigate this URL and then it would do the same thing a login page would have done. Store this token wither in cookies or localStorage. Once done the page should redirect to the returnURL

    This way the app will without any re-login required from the SFSafariViewController