Learn Courses My Dashboard

API Login with SwiftUI

I am building an application where a user first has to login in the app. The application does logging in with an API that I created. This API returns an API Token with has to be used for all further requests during the session. Does anyone have an idea how the logic behind this is to be implemented or has a link to a guide or tutorial how to do this in SwiftUI?

Thanks in advance!

Welcome to the community!

Have you made the API call at all?

You can do this in a view model, and the data that’s returned save it into Keychain

Then from there fetch the Keychain value and use it in your network calls

Thanks for the reply! I am working on it now and have roughly implemented it. Will now refine the written code. Only struggle I am having is how to reuse the API calling function and how to return the output of the API to a given structure…