android - RESTfull web service using oAuth for mobile application -


i building application consists of 2 main parts:

  1. web application rest api.
  2. mobile application(android, iphone).

web application has database stores data users (like posts, events , similar).
mobile application uses web application's rest api access data, need kind of authentication (user must authenticate in order access/modify data).

i know done in such way mobile application provides username , password in each request towards web api, , web application authenticates username , password against database before serving request.
however, use oauth (so user can login using google, facebook, ...) , things complicated, , not sure best way this.

my first idea: mobile app sends oauth provider (for example facebook) credentials (username , password) web app, authenticates them against oauth provider. realized not ok because means user has trust site not abuse given credentials, not way done. not good

my second idea: mobile app uses web application api tell web app wants authenticate against oauth provider p. web application redirects provider p user inputs credentials. after provider p redirects web application user logged in , json successful login sent mobile app. great if not part user has input credentials manually. implemented solution , problem that, after mobile app accesses web app api json not returned first redirects done , messes up. thinking using webview inside mobile app, don't know how return webview when json sent. not sure if should pursue idea further or wrong way of doing it? maybe if problems solved

my third idea: mobile app authenticates directly against oauth provider p. if successful mobile app sends requests web app containing user information (for example userid, or user password) web app knows user is. means web app has trust mobile app given user authenticated. means web app needs sure api accessed mobile app. hardcoding special password(secret) in mobile app sent each request prove request sent mobile app.
bad side of approach have implement mobile app authentication against oauth provider each combination of (mobile os, oauth provider). not sure how secure it. think way go, improve/change? have feeling missing something. maybe good, has many work do

please tell me idea best , if there way improve them, thanks

after further research , talking of colleagues decided best option go second idea. decided handle redirects using webview (which exists both on iphone , android). webview configure in such way automatically exits when user redirected specific url on web app returns json.
decided best idea because way have implement/configure webview on mobile app while oauth logic done on web app means there less code repetition among mobile apps (android, iphone) , more extendible (i have modify 1 web app, not 2 or 3 mobile apps).


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -