This is the fourth post in the series over oAuth with Symfony2, iOS and Android. All posts in this serie can be found here.
With this post we are continuing to work on the Android app, and start adding the needed oAuth libraries and adding network functionality.
All code from this post can be found here at Github. Because wordpress doesn’t seem to work that well with the included code in this blog, I suggest to use the code from the repository. I created a tag in the repo for the part that was at the end of this second part.
I assume within this post that you are at the same stage with your code as we ended in part 1.
To handle all oAuth related requests we are going to use a library that does all the hard work for us. This library can be found on Github.
Lets start with adding this library to our app. Because I am using Android Studio, dependencies and things like that are not handled by maven, but with Gradle. You should edit the build.gradle which is located in the android directory, not in the root!
Add in the dependencies section the next line:
This is the third post in the series over oAuth with Symfony2, iOS and Android. All posts in this serie can be found here. While the previous post about symfony2 was one large post, I am going to try splitting this in a few posts.
All code from this post can be found here at Github. Because wordpress doesn’t seem to work that well with the included code in this blog, I suggest to use the code from the repository. I created a tag in the repo for the part that was at the end of this first part.
With android, there are several possibilities to do the actual development. While Eclipse is (Still) the preferred IDE, I actually like Android Studio more (And I am pretty sure Android Studio will soon fully replace Eclipse with their ADT).
The only disadvantage sometimes are the many releases of Android Studio, with sometimes features that break stuff in your project. The current version from Android Studio that I will be using for this project is 0.5.8, with tools version 22.6.
Testing the app will be done on a Nexus 7 (First version) with Android 4.4. I won’t be using the emulator.
In a few projects I made in the last few months I wanted to use a method to login at a custom site within a app on Android or iOS. Using the username/password combination from the website itself didn’t seem to be a great idea, so that was scrapped directly.
I decided to look into using oAuth2 for accessing the API that was created on the website for authorisation. oAuth2 seems to be a commonly used, by companies like Google, Facebook and GitHub. Searching for simple implementation for both Android and iOS showed a few libraries, but all of them weren’t documented that well.
With this serie of blog posts I am going to try making a simple example website that contains a simple REST API written in symfony 2. This API will be called with 2 apps, 1 iOS app and 1 Android app. These apps are very simple, and have no other features/usages within this example. They are created just to show how to integrate the oAuth2 part into a app.
All code by used within this serie will be published at github, see the specific posts for the repository for that part of the project. The project is split up in 3 separate repositories.
While this project is ment to be a example for creating oAuth authorization, I still assume you have basic knowledge about both Symfony2, as iOS and Android programming. I won’t be explaining how to create a basic project for these three setup. All exampled that I publish are working and tested examples.
This serie is split up in more then one blogpost, in every blogpost I try to concentrate myself on one component in this project. Due too time constraints I won’t be able to publish all posts directly from the start, I will try to publish a post once every week.
In case of questions/mistakes/spelling errors/etc/ please leave a comment on the specific blog post. I will try to answer them as soon as possible.