Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

October 27, 2011

Using Google Authentication - via AccountManager - to access Google services on Android devices

* Attention *      This is a Work in Progress (WiP)      *Attention *

This post will cover the use of AccountManager (available in Android 2.0 and onwards) to access Google Accounts online.

It is a research article I am putting together mainly for my own use but my preliminary research revealed very few postings on the net, so I thought I'd keep it available online, so that it is accessible to more people as well as being a note board for myself.

It is possible to authenticate Google Accounts using HTTP requests but this requires the user to supply the app with both username and password, which is neither comfortable or convenient for the user. Using Google Authentication it is possible to use information already stored in the Android device to authenticate towards Google services without the Application needing access to username or password.

And authentication handled by AccountManager is handled in a generic way regardless of application.

I am performing this research in order to use it in my own Apps, primarily Analytics 4 Android (Free), but  hopefully general application in your instance should be fairly easy. Please feel free to comment.

In this article I will be citing other works. I may/may not have asked for permission to do so, but I am hoping that if You are an author and/or publisher of any said works will treat them as fair use. I will try to provide adequate attribution and reference for any works used. If You feel that I am violating your copyright, please feel free to contact me on janholbo(at) gmail (d ot) com.


References:

  1. AccountManager (Android Reference material), http://developer.android.com/reference/android/accounts/AccountManager.html
  2. AndroidAccountManager (google-api-java-client), http://code.google.com/p/google-api-java-client/wiki/AndroidAccountManager
  3. Authenticating against App Engine from an Android app (Nick's Blog), http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app

Links to be researched:

Other links:

March 04, 2010

Google Analytics Application/Widget for Android

Last Update:  March 17th, 2010 9:42 CET

I have started work on an Application/Widget that can retrieve and display data from Google Analytics, for mobile phones running on the Android platform.

This will be my first application and Widget for Android and as such it is both a learning as well as a production project as the outcome should be a usable Application/Widget.

As work is still in its very early stages and I need to research both Android development and how to use the Google Data API from Java/Android there is not much to show yet. I will put up an article on our web site, when there is more to show.

Update March 12th:
I now get an authorization token when providing my own correct google login. Failure is detected and parsed but not parsed properly and user is not informed. User info is probably going to be delayed - I'd rather try to get some data first ;-)

For progress/project status please look further down.

Update March 17th:
The past few days nothing (seems to have) happened. Partly due to other engagements, work etc. Partly because I started fiddling with the UI and that broke something, which I could not figure out. I have been writing a few lines of code which will be the start of managing Accounts and Profiles.

I have rethought the UI and the way the App/Widget will be set up, including the way it is set up in my IDE (Eclipse). I have also decided to change the name of the App/Widget, which was a working title anyway. Hopefully later today I will have put up a web page on the App/Widget with the new name. I will also change the way I update the info. So far I have just kept editing this post. From today I will make a new post with the changes only and then put the status on the web page. When the web page is ready, I will post the URL here.

Status: Version 0.10 - alpha state

Next mile stone: V. 0.20 - Account Query (request profiles)

To Do (anticipated version):

  • Authenticate user (V. 0.10 - DONE!)
  • Account Query (request profiles) (V. 0.20)
  • Report Query (V. 0.30)
  • Widget setup (V. 0.40)
  • Widget display (V. 0.50)

Progress:

March 12th, 2010
Version 0.10

  • Authentication of Google Analytics Account code
    • HttpRequest code based upon a post by Rich Stern : http://blog.richstern.com/?p=32
    • Google now authenticates my personal account and an authorization token is returned.
    • Still need to parse the HttpResponse properly
      • Determine response from Google (DONE)
      • Inform user of failure/success (showing dialog upon Authorization already)
      • Save authorization token on succes (DONE)
    • ... time to head for the second mile stone! Whoop!

March 12th, 2010
Version 0.05
  • Authentication of Google Analytics Account code
    • HttpRequest code based upon a post by Rich Stern : http://blog.richstern.com/?p=32
    • Google now authenticates my personal account and an authorization token is returned.
    • Still need to parse the HttpResponse properly
      • Determine response from Google (partly done)
      • Inform user of (possible) failure
      • Save authorization token on succes (DONE)
    • ... but I am half way to the first mile stone! Yay!
March 11th, 2010
Version 0.04
  • Authentication of Google Analytics Account code
    • based upen code from a post by Rich Stern : http://blog.richstern.com/?p=32
    • Google now authenticates my personal account and an authorization token is returned.
    • Still need to parse the HttpResponse properly
      • Determine response from Google
      • Inform user of (possible) failure
      • Save authorization token on succes
    • ... but I am almost half way to the first mile stone! Yay!
March 10th, 2010:
Version 0.03
  • code for reading UI contenst Username and Password added
  • Authentication of Google Analytics Account code started
March 4th, 2010:
Version 0.01
  • Project started.
  • UI for adding accounts started
  • No working code yet

January 08, 2010

Developing on Android - problems installing ADT

While trying to install the ADT on a Ubuntu 9.10 Karmic Koala using the Ubuntu Eclipse package I get the following errors trying to add ADT to Eclipse:

Cannot complete the install because one or more required items could not be found.
  Software being installed: Android Development Tools 0.9.5.v200911191123-20404 (com.android.ide.eclipse.adt.feature.group 0.9.5.v200911191123-20404)
  Missing requirement: Android Development Tools 0.9.5.v200911191123-20404 (com.android.ide.eclipse.adt.feature.group 0.9.5.v200911191123-20404) requires 'org.eclipse.gef 0.0.0' but it could not be found

Next step would be to remove Eclipse and reinstall it from a tarball I guess ....

Does anybody else got to this road-block and perhaps passed it?