iOS and Server: OAuth strategy
Posted
by
drekka
on Programmers
See other posts from Programmers
or by drekka
Published on 2012-06-25T01:31:27Z
Indexed on
2012/06/25
3:22 UTC
Read the original article
Hit count: 314
I'm trying to working how to handle authentication when I have iOS clients accessing a Node.js server and want to use services such as Google, Facebook etc to provide basic authentication for my application. My current idea of a typical flow is this:
User taps a Facebook/Google button which triggers the OAuth(2) dialogs and authenticates the user on the device. At this point the device has the users access token. This token is saved so that the next time the user uses the app it can be retrieved.
The access token is transmitted to my Node.js server which stores it, and tags it as un-verified.
The server verifies the token by making a call to Facebook/google for the users email address. If this works the token is flagged as verified and the server knows it has a verified user. If Facebook/google fail to authenticate the token, the server tells iOS client to re-authenticate and present a new token.
The iOS client can now access api calls on my Node.js server passing the token each time. As long as the token matches the stored and verified token, the server accepts the call.
Obviously the tokens have time limits. I suspect it's possible, but highly unlikely that someone could sniff an access token and attempt to use it within it's lifespan, but other than that I'm hoping this is a reasonably secure method for verification of users on iOS clients without having to roll my own security.
Any opinions and advice welcome.
© Programmers or respective owner