1

Currently, I have a Django-backend site with rest-framework-auth setup and functioning as far as the default web portal. I see many tutorials on how to remain authenticated with token authentication, but nothing that shows how to perform the initial authentication where you receive the authentication token. How do I make the initial request with the username and password to receive the token?

After authentication, although code is not written yet, I want to look into storing the authentication token with the IOS Keychain API so the user can login once and stay logged in like most apps.

I have previously tried solutions such as the following SO Answer and tutorial page: -https://stackoverflow.com/a/42532121/11915500 -https://developerslogblog.wordpress.com/2017/02/26/basic-authentication-in-swift-3-0/

However, with both of the above, for me, inputting valid authentication credentials returned a 400 status code, and invalid credentials returned a 403 status code.

I would prefer to do this using native classes like NSURLSession rather than installing Alamofire or similar libraries if possible.

Sorry for no source code, but I have nothing to go off of with this issue. Also, if there are any issues with the nature of the question, I apologize again, this is my first post.

nickid0419
  • 11
  • 2
  • Welcome! Can you please provide source code for what you would do after performing initial authentication? That way it's easier to get a sense of what exactly you're looking for. Also, linking to resources you've looked at can be helpful as well. – Michael Kolber Aug 12 '19 at 19:21
  • Thank you! I edited the question according to what you asked. I don't have source code for what I am doing after initial authentication really, because I am also unsure of exactly how to store the key securely. My thinking was that I wanted to grasp how I'm getting the key before I start making other requests with it. – nickid0419 Aug 12 '19 at 19:52

0 Answers0