Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OAuth/OpenID across a web/mobile app

I'm currently designing a service that will be half web app, half android app. Each user will need to be able to log in from either the android app or the web app, using an openID account. I'm hoping to target Google first for easiest integration with Android, but I'll also need some OAuth stuff later so that I can integrate with Google contacts.

The bit I'm having trouble with is how to authenticate users. The structure I've planned is that the server (probably using web.py, although that's flexible right now) serves data for the client in JSON, whether the client is the javascript browser client or the android client. However, each call needs to make sure the client is allowed access to that data.

  • What would be the easiest way to standardise this across the platforms?
  • Should I be using a session system to authenticate after logging in? Can that be made to work from an Android app? Otherwise, should I simply authenticate with google for every request?
  • When authenticating from the app, where should the authentication happen, through the server or straight from the app? Where should the auth token be stored in this case? (I'm assuming for a straight webapp the token should just be stored in a table in the user database?)

Sorry for the barrage of questions, but I haven't really found any resources online that clarify these issues very well.

like image 259
olane Avatar asked Feb 18 '26 07:02

olane


2 Answers

As long as you are using HTTP, the platform doesn't matter. You can use the same form of authentication and/or sessions. The only difference would be that on Andorid you might be able to get an authentication token using the platform's AccountManager, without having to type the username and password in Google's login page.

like image 145
Nikolay Elenkov Avatar answered Feb 20 '26 20:02

Nikolay Elenkov


There's a subtle difference between Authorization (OAuth) and Authentication (OpenId). Make sure you know what you are doing.

like image 36
Artem Oboturov Avatar answered Feb 20 '26 21:02

Artem Oboturov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!