MyGlass认证”;无效值“;Java示例和PHP库的响应


MyGlass Authentication "Invalid Value" Response with Java Example and PHP Libraries

我正在尝试为我的GDK应用程序设置MyGlass身份验证,就像在使用PHP的Google Glass GDK身份验证中一样。用户通过MyGlass登录我的网站,进行身份验证,然后我尝试使用Mirror API插入帐户。

我正在使用中描述的"工作"PHP示例http://goo.gl/DVggO6.然而,我总是从Google API服务器返回一个错误,说"无效值",没有进一步的信息。

我已经仔细检查了我的密钥和密钥文件,并验证了镜像API快速启动是否有效。所以一切似乎都应该正确设置。

除了提供解决方案外,有人能提出解决问题的方法吗?在本地Web服务器上运行它并使用Wireshark检查POST主体的最佳途径是什么?


Google_Service_Exception with message Error calling POST https://www.googleapis.com/mirror/v1/accounts/bfb41d5c745d***/com.lumilogger.glassware/username%40email.com?key=********: (400) Invalid Value in /home7/tallyhea/public_html/Google/Http/REST.php:81 
Stack trace: 
#0 /home7/tallyhea/public_html/Google/Http/REST.php(44): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request)) 
#1 /home7/tallyhea/public_html/Google/Client.php(503): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request)) 
#2 /home7/tallyhea/public_html/Google/Service/Resource.php(195): Google_Client->execute(Object(Google_Http_Request)) 
#3 /home7/tallyhea/public_html/Google/Service/Mirror.php(409): Google_Service_Resource->call(insert, Array, Google_Service_...) 
#4 /home7/tallyhea/public_html/functions.php(55): Google_Service_Mirror_Accounts_Resource->insert(bfb41d5c745***, com.lumilogger...., username@email..., Object(Google_Service_Mirror_Account)) 
#5 /home7/tallyhea/public_html/glass_oauth.php(71): insert_account(Object(Google_Service_Mirror), bfb41d5c74***, username@email...) 
#6 {main}"

从服务器返回的JSON响应相当神秘:

body: { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid Value" } ], "code": 400, "message": "Invalid Value" } }

我还尝试了Glass的MyGlass认证页面的Java示例,但得到了相同的错误:

Invoking createAccount()
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid Value",
    "reason" : "invalid"
  } ],
  "message" : "Invalid Value"
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1049)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at glassAuth.GlassAuth.createAccount(GlassAuth.java:96)
at glassAuth.GlassAuth.main(GlassAuth.java:52)

这可能是由code.Google.com上谷歌API的错误配置或类似原因引起的吗?

也许我不能插入帐户,因为谷歌不知道我用来插入帐户的"帐户名"?

所以我不再得到错误400响应,也不再得到任何错误。我还没有在Glass方面进行测试,但现在可能可以工作了。秘密是在调用insert(userToken,ACCOUNT_TYPE,accountName,ACCOUNT)时,在ACCOUNT_TYPE字段中使用"lumilogger"而不是"com.lumilogger.glasser"。

事实上,回顾我的Glassware审查请求电子邮件(谷歌今天为我更新了该电子邮件),我没有指定"帐户类型"。但今天他们将其更新为"lumilogger"。现在,通过使用此帐户类型插入,问题就解决了。

经验教训如下:1.您需要在审核请求中指定帐户类型。2.您传递给insert()的帐户类型是您在(1)中指定的,而不是您的APK包名称(例如com.google.test等)。