How to structure authenticated app?

I have been working for a while on an app that uses createHTTPClient in a lot of different places to hit my API. Now, I have enabled authentication for a lot of my API services. As expected, I am receiving

{error:"access denied"}

Is there a global hook where I can check for access_denied and move the user to the login screen? Should I wrap HTTPClient and centralize this check myself? How would you recommend I structure an app for authentication?

1 Answer

  • Hi

    Have you seen the new additions to the httpClient that are in Ti SDK 3.0.0 GA?

    If you have set up authentication then these should help you out.

    — answered 3 years ago by Malcolm Hollingsworth
    • Those docs are pretty light. How can I find out what type of authentication that is related to / how the credentials are persisted / etc? Also, is there a way to see / clear the cookies that my server is using for this? It looks like headers are getting stripped out of my responses.

      — commented 3 years ago by Joseph Beuckman
      • On iOS this will enable NTLM authentication
      • For Android, custom AuthSchemeFactory

      You can find more here in the ticket.

      You are going to need to provide some code to work out why you are losing things.

      — commented 3 years ago by Malcolm Hollingsworth