com.google.gdata.client.GoogleService.setUserToken(android.accounts.AccountManager.getAuthToken(???))

后端 未结 1 1959
小鲜肉
小鲜肉 2021-02-11 02:50

I\'ve got working code that uses the gdata to retrieve feeds from my user\'s Google Finance portfolios, but I had to use setUserCredentials(username,password). What I\'

相关标签:
1条回答
  • 2021-02-11 03:28

    AccountManager.blockingGetAuthToken() is the correct call. Pass it an Account, and an String authTokenType -- In your case, "android" or "finance", your pick (the values of the strings it's looking for are not clearly documented).

    The easy way to obtain an account is to do all your client comms as part of the onPerformSync() call on a class that implmenents a Sync Adapter. You can find a number of tutorials on getting a SyncAdapter set up. As part of getting your SyncAdapter going, you'll end up with a mess of permissions, probably like the following or so:

    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    <uses-permission android:name="android.permission.USE_CREDENTIALS" /> 
    <uses-permission android:name="android.permission.WRITE_SETTINGS" /> 
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> 
    <uses-permission android:name="android.permission.READ_SYNC_STATS" /> 
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> 
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /> 
    <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" /> 
    <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.finance" />
    

    Those last two, again, sort of tricksy, dug them out of who knows where.

    0 讨论(0)
提交回复
热议问题