6
votes

My task is to write IMAP e-mail client for Gmail. So far I know client should authenticate through OAuth (there's also a java library for IMAP auth by Google). But I'd like to set user free from any password typing.

Android provides a cool 'native' way to gain authToken for google account services via AccountManager. But I wonder how to use authToken and what is it for? Is it only for GAE authentication?

Is there any way to get oauthToken and oauthTokenSecret without browser (via AccountManager)?

1
Check out this talk from Google IO 2011. There's a pretty good user-experience for newer Android devices using the AccountManager described. - David Snabel-Caunt
Thanks! But I've already looked through this library and found there's no gmail interaction in Google API. Sad but true, I have to use IMAP. Or do I miss something? - Oleksii Malovanyi
I don't know for certain, but I'm sure GMail can be accessed via OAuth. I'm using Chrome extensions which can do so. - David Snabel-Caunt
OAuth? Certainly. The point was to use Account getAuthToken method and provided authToken for OAuth. But for Gmail it's seems to be impossible. - Oleksii Malovanyi
Thanks for response. The problem remains. If scope-related problem is solved, than next problem is to figure out how to use this authToken for servers where OAuth tokens are needed. - Oleksii Malovanyi

1 Answers

4
votes

Have you tried using "oauth2:https://mail.google.com/" as the "auth token type" (authTokenType parameter) when calling AccountManager.getAutToken() ?

According what is said at 46:50 in the talk you mentioned, it should work.

By the way, this page describes how to get an OAuth2 token for Google Tasks, and it has a link to a code sample. It also makes it sounds like it is just a matter of providing the right authTokenType parameter.