Say you have a REST API that you want to protect with an OAuth based authentication system. The regular flow using the website I'm using is:
- user clicks a link to login to google
- google makes a request to the callback you specified
- your application responds to the callback by taking the given tokens and requesting the user data, finding what that user data corresponds to on the database and giving you back a session cookie for the web application and an HTML redirect (for example to the home or whatever you prefer)
Basically the callback endpoint transforms google tokens into your web application session cookies.
Now I'm wondering: how would that work for a mobile application that doesn't know anything about cookies or redirects? It could do:
- on google button click, make HTTP request to the google auth URL
- google responds with the callback URL you specified
- the app makes another request to the above mentioned callback URL to your application
- your application returns a cookie session value and a redirect URL to the homepage
- the mobile applications forgets about the last redirect URL and takes the cookie session value and uses that for any other requests to the API
Is that right?