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

查看:163
本文介绍了com.google.gdata.client.GoogleService.setUserToken(android.accounts.AccountManager.getAuthToken(???))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有工作,它使用GDATA检索我的用户的谷歌财经的投资组合的饲料code,但我不得不使用的 setUserCredentials(用户名,密码)的。我想要做的是避免要求用户输入自己的用户名/密码,因为Android设备已经可以访问他们的谷歌帐户。

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'd like to do is avoid asking the user for their username/password since the Android device already has access to their Google account.

我相信我应该可以用的 setUserToken(字符串)的做到这一点,但我无法弄清楚如何从Android的相应标记。我试过的 AccountManager.get(上下文).blockingGetAuthToken()的但是这要么不正确的电话或我传递了错误的参数。

I believe I should be able to do this with setUserToken(String), but I can't figure out how to get the appropriate token from Android. I've tried AccountManager.get(context).blockingGetAuthToken() but that's either not the correct call or I'm passing it the wrong arguments.

有没有人得到GDATA与用户现有的谷歌凭证在手机上正常工作?

Has anyone gotten gdata working with the user's existing Google credentials on the phone?

在此先感谢, 莱尼

推荐答案

AccountManager.blockingGetAuthToken()是正确的调用。它传递一个帐户,和字符串authTokenType - 在你的情况,机器人 财经,你的选择(它寻找字符串的值都没有明确记载)。

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).

最简单的方法获得一个账户是做所有客户端通讯科为 onPerformSync()上implmenents一个同步适配器类调用的一部分。你可以找到获得一个SyncAdapter设置了一些教程。至于让你的SyncAdapter会的一部分,你会拥有权限的一塌糊涂,很可能像下面的左右:

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.

这篇关于com.google.gdata.client.GoogleService.setUserToken(android.accounts.AccountManager.getAuthToken(???))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆