Once you figured out how OAuth works, you might ask yourself how this principle works from within a native Android app. It’s actually easier then expected at first. There exist some libraries that can make our life somehow easier, but I decided not to use any of them and to do everything from scratch.
This is the OAuth workflow for Foursquare:
- A call to the Foursquare server is made with the client id and a redirect URL (has to be in a browser)
- The user accepts the access request of the application
- Foursquare calls the redirect URL with special code as parameter
- The Foursquare server has to be called again with the client id, client secret, the code and the redirect URL (not in the browser anymore)
- Foursquare returns now the access token which has to be saved by the app
- Further calls to the Foursquare API can be made with the token
