I am looking to create a 'secret key' for my iOS app to lock down my API so only people with the “key” have access.
It is my first app built using Swift and is pretty basic.
It currently connects to my database using a users email and password.
All database connections are handled via JSON with the API sent in the URL.
I have been advised that to secure this, would mean to lock down my API so only people with the “key” have access.
I have installed an SSL certificate through letsencrypt.org and now wish to create this secret key but I don't know where to start.
I have found various resources but they are either for Obj-C or Swift 2.1
Prior to this information above I was looking to implement OAuth2.0 or REST API but I was told neither of these are the right solution for what I need, and I was overcomplicating my issue.
I have been advised to create a 'secret key' for my iOS app to lock down my API so only people with the “key” have access.
I have been looking at this thread:
In iOS, how can I store a secret "key" that will allow me to communicate with my server?
and
https://github.com/rnapier/RNPinnedCertValidator
But the latter is Obj-C and the former does not give me enough information.
I have tried converting the Swift 2.1 code but I am unsure as where I need to put the code. For now I have placed it in my App Delegate.
The errors can ben seen in the image below - 2 are unidentified identities, 1 x argument label does not match available overload, and 1x cannot invoke initialiser of type.
Thanks