Android Sync Adapter with Google User Account Applications

I am using a sync adapter for my app to sync with the appengine backend. In appengine, I use the built-in User api for authentication. There is a message HERE that says how to do this, however the application is listed in the gmail account. Ideally, my application will be listed in the accounts. I don’t want to ask the user for a username and password, just use your existing google account for authentication. Has anyone done this before?

Update: I worked on this, and it looks like I can implement AuthenticationService and save the user account name and leave the password as an empty string. In getAuthToken () methods, I should just return google auth token. There will be a post after I continue ...

+7
source share
2 answers

You may have misunderstood the Android account system. When you go to Settings β†’ Accounts and sync and add a new account, you will see a list of account types. Often there is a relationship between account types and applications, for example, Facebook accounts are used with Facebook. Usually you add a new type of account if you have another backend system for authentication processing, etc.

If you understand correctly, you are using Google accounts, but want it to appear as your own account type. That sounds wrong to me. In the end, you will override the processing of your Google account, but it will not matter much. I find it easier for users if you simply agree to what Google provides you. When you click on an account, your application / service / content provider can be seen. For example, after setting "Tasks" in the "Team Task" (disclaimer: I am not an affiliate of this company) they add "Synchronization Tasks" to the list of data and synchronization parameters.

But if you really want to create your own account type, follow the sample Sync adapter example . Find the Authenticator code and related resources (e.g. manifest, action layout, etc.).

+3
source

It is really possible, and I have implemented it with success, but I warn you that this is a bit of a headache.

There is an excellent tutorial available called writing-an-android-sync-provider-part-1

... remember to check the following in part 2

In addition, there is a SampleSyncAdapter in the Android SDK examples, which was invaluable in my development.

With a little hard work and a lot of coffee, you should be able to get this job;)

+2
source

All Articles