background preloader

Accounts

Facebook Twitter

iPhone & iPad applications. Write your own Android Authenticator. When I wrote Any.DO’s sync system, about 18 months ago, I wanted to use the built in AccountManager API to authenticate and store the users’ credentials.

Write your own Android Authenticator

When I used it to access Google accounts it seems a pretty simple experience, so I thought I should do that for Any.DO as well. It also goes very well with a sync mechanism (using a SyncAdapter), making it the perfect solution. The problem - no good documentation was out there. The developers community didn’t have much experience with that back then, and since we didn’t have much time to figure out issues that could arise from this “No man’s land”, a decision was made to use other methods. But times have changed.. I recently studied that feature again for a project I’m working on, and saw there’s a huge improvement with the knowledge about it.

But..they all still miss something. I didn’t feel that I actually know everything I wanted to know about the process, and some parts weren’t clear enough. Why Account Manager? Why really? AddAccount. Android: Account Manager: Step by Step. Download Project: Android Account Authenticator and Service Every information system requires account authorization and authentication.

While it is easy enough to implement your own, Android provides a solid and consistant framework for you to use. This is the first of a two part article that shows you how to implement an Account Authenticator in Android. In this part we are simply going to get our application to show up in the Account Manager as seen in the image below. (AccountAuthenticator) Note: Clicking on the list item will do nothing as we are not implementing the methods in the AbstractAccountAuthenticator in this lesson. This requires the following steps: Extend the AbstractAccountAuthenticator Implement the abstract methods from the AbstractAccountAuthenticator Implement an Authenticator Service Define the account authenticator properties Register the service in the AndroidManifest.xml with an Intent Extend the AbstractAccountAuthenticator Implement the abstract methods. Creating An Authenticator for Android Applications. These are notes from my time learning to work with the Android AccountAuthenticator.

I wrote thois primarily for myself and have only brushed it up a very little bit before posting it. The hope is, that it may help somebody but this is not a tutorial. I just write stuff down like that to understand it myself. But I’m happy if some of it may be usable for someone. The Project This project is to create an AccountAuthenticator for android that will use a REST interface to authenticate itself and get a token back that can be used by aplications to authenticate themselves with the server. The second part is to integrate the authenticator into existing projects as to not have it installed seperatly. Creating the Classes and XML Files Create A new Android Project. The first class to write is the actual AccountAuthenticator which has to extend the AbstractAccountAuthenticator. //The implementation is based on the tutorial by Adam Pullen ( return result; } public static final int REQ_CODE_CREATE = 1; Switch Your Coding Life: Android - Account manager - Part I.

1. Introduction By default, Android incorporates an Account manager, which is used to store user's credentials and sync with the server, if necessary. It's use has been encouraged by the Google's guy on Android I/O 2011: 2. Basic notions The account manager is a centralized service offered by Android system. Any application can get the list of accounts and request the user to utilize its auth tokens. Basically it contains a list of Accounts, each one is identified by: Account name : The user name used to log in. All the accounts should be unique across a device. For each one of the accounts, there is a set of data related with it: Password : The password of the account. 3. There are several permission required to interact with the account manager: android.permission.GET_ACCOUNTS This permission is utilized to get the list of accounts and check if a specific account has a specific feature. Android.permission.USE_CREDENTIALS.