简体   繁体   中英

How to request an auth token for multiple services using AccountManager?

Is it possible to request an auth token using AccountManager for more than one service at the same time?

Basically I need access to both the Google Docs API (writely) and the Spreadsheet API (wise).

I tried with a space ("writely wise") and with a comma ("writely,wise"), but it doesn't seem to work with either.

From here ( http://code.google.com/p/google-api-java-client/wiki/Android ) I know that for OAuth 2.0 you can use a space, but the Google Docs API uses ClientLogin and nothing is mentioned there.

If I need to request an auth token for each service separately, what is the best way to go about it? Do I need to invalidate the token each time I need to change service?

The only thing that I need from the Spreadsheet API is to be able to export a spreadsheet as CSV. All the rest that I need can be done with the Docs API.

While experimenting with the Spreadsheet API, I wondered about the same question. I started from https://github.com/joeledstrom/SpreadsheetTest and adapted it to work with API client version 1.6.0, by following the approach in the "Picasa Android Sample". Requesting the tokens for both services separately and using them in two distinct request factories works fine. The only tricky issue is that now you have to also deal with the two intents for requesting authorization from the user that getAuthToken returns.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM