新发布的"认证与谷歌播放服务] ;,问题通过GoogleAuthUtil.getToken获得令牌 [英] Newly released "Authentication with Google Play Services", Problems with getting a token via GoogleAuthUtil.getToken
问题描述
更新:
我刚才签署了谷歌API的谷歌帐户我还使用了谷歌App Engine和现在错误已经更改为 com.google.android.gms.auth.GoogleAuthException:未知
Just now I signed up to Google API with the Google account I'm also using for the Google App Engine and now the error has changed to com.google.android.gms.auth.GoogleAuthException: Unknown
谷歌刚刚发布了一个新的方式来通过谷歌帐户注册为自己的应用程序并给他们的<一一些解释href="http://android-developers.blogspot.com.au/2012/09/google-play-services-and-oauth-identity.html"相对=nofollow>博文了。
Google just released a new way to sign up to one's app via a Google Account and has given some explanation in their blogpost, too.
我正在写一个Android应用程序,你必须注册创建一个用户帐户,我使用谷歌应用程序引擎的后端。随着该剧的服务,我想获得用户的Android设备和令牌电子邮件下属。我已经可以收到电子邮件,但是,得到令牌只能抛出错误并且由于文件是相当稀疏,我不知道如何解决这些。这就是我获得的电子邮件:
I'm writing an Android app you have to sign up for to create a user account and I'm using Google App Engine for the back end. With the play services, I want to get the users email affiliated with their Android device and a token. I can already get the email, however, getting the token only throws errors and due to the documentation being quite sparse, I don't know how to fix these. That's how I get the email:
private String[] getAccountNames() {
mAccountManager = AccountManager.get(this);
Account[] accounts = mAccountManager.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
names = new String[accounts.length];
for (int i = 0; i < names.length; i++) {
names[i] = accounts[i].name;
}
return names;
}
然而,当我打电话标记= GoogleAuthUtil.getToken(背景下,电子邮件,
范围
,它给了我这些错误:
不可用是由于错误GooglePlayServices 1
和 com.google.android.gms.auth.GooglePlayServicesAvailabilityException:GooglePlayServicesNotAvailable
However, when I'm calling token = GoogleAuthUtil.getToken(context, email,
"scope"
, it gives me these errors:
GooglePlayServices not available due to error 1
and com.google.android.gms.auth.GooglePlayServicesAvailabilityException: GooglePlayServicesNotAvailable
.
现在我的问题是,我设置任何权限或包含任何库来解决这个问题?和范围是什么参数?对于如何获得令牌,什么投入的范围内给出了一个例子在其博文设置范围变量https://www.googleapis.com/auth/userinfo.profile
但我仍然得到同样的错误很遗憾。
Now my question is, do I have to set any permissions or include any libraries to fix that? And what is the scope parameter? An example for how to get a token and what to put in for scope is given in their blogpost to set the scope variable to "https://www.googleapis.com/auth/userinfo.profile"
but I still get the same error unfortunately.
我也注册了我的应用程序的谷歌API控制台并启用了G + API,我必须配置别的东西在那里,太?
I also registered my app for the Google API console and enabled the G+ API, do I have to configure something else there, too?
推荐答案
我不得不使用谷歌客户端库对谷歌驱动器同样的问题。 解决的办法是pretty的方便。只要prePENDoauth2:你scopeUrl
I had the same problem using the Google Client Library for Google Drive. The solution is pretty easy. Just prepend "oauth2:" to your scopeUrl.
错误:
GoogleAuthUtil.getToken(this, account.name, DriveScopes.DRIVE);
右:
GoogleAuthUtil.getToken(this, account.name, "oauth2:" + DriveScopes.DRIVE);
这篇关于新发布的&QUOT;认证与谷歌播放服务] ;,问题通过GoogleAuthUtil.getToken获得令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!