Design for Facebook authentication in an iOS app that also accesses a secured web service

Digital Marketing Facebook Marketing API 2 years ago

0 0 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ Goal: Allow a user to authentication with Facebook into an iOS application which requires access to a protected web service that I'm running. Assumptions: There is a native authentication (and registration) system in place for those users that opt not to use Facebook for sign in. Details: Assume we want to offer the option for a user to sign in with Facebook without creating a separate account/credential for our system. Because we support our own native auth mechanism (username and password) we have our own user IDs and issue an authentication token that is used for subsequent interactions after the initial credential validation. I'm surprised that Facebook doesn't have best practices for this in their developer documentation. All the existing documentation is either assuming you are building FB auth into a website, or a standalone mobile app with no service that requires authentication. Here's my initial thoughts on how this would be designed but want validation on whether it's correct. Client pops the Facebook iOS Login UI User signs in with Facebook credentials and gets access token iOS App passes access token to our server Our server talks to FB graph API using access token to (a) validate the token and (b) get the FB user ID for that access token. e.g. Our server would call https://graph.facebook.com/me/?access_token=XYZ which would return profile info in a JSON object Assuming it's valid, our server extracts the User ID from the JSON object and checks whether the user already has an account. If so, we issue our own auth ticket to client to use for that session. If user doesn't have an account, we create a new one with the Facebook User ID, assign our own unique UserID and issue our auth ticket. Client then passes auth ticket back on subsequent interactions that need authentication. This seems like the right approach to me but not sure if I'm missing something insanely basic and going down the wrong (complicated) path.

Posted on 16 Aug 2022, this text provides information on Facebook Marketing API related to Digital Marketing. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (0)

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.