Reputation: 21
I am trying to setup MyGlass authentication for my GDK app, as in Google Glass GDK Authentication using PHP. The user logs into my site through MyGlass, authenticates, and then I try to insert an account using the Mirror API.
I am following the "working" PHP example described at http://goo.gl/DVggO6. However, I always get an error back from the Google API server saying "Invalid Value", with no further information.
I already double checked my keys and key files, and verified that the Mirror API Quick Start works. So everything seems like it should be setup correctly.
In addition to providing a solution, can anybody suggest methods to troubleshoot the problem? Is the best route to run it on a local webserver and using Wireshark to inspect the POST body?
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}"
And the JSON response back from the server is rather mysterious:
body: { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid Value" } ], "code": 400, "message": "Invalid Value" } }
I also tried the exact Java example shown for Glass's MyGlass authenticate page, and got the same error:
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)
Could this possibly be caused from incorrect configuration of the Google APIs on code.google.com or something like that?
Maybe I cannot insert account because Google doesn't know the "Account Name" I am using to insert accounts?
Upvotes: 1
Views: 414
Reputation: 21
So I no longer get the error 400 response, or any error for that matter. I haven't tested it yet on the Glass side, but its probably working now. The secret was to use "lumilogger" instead of "com.lumilogger.glassware" in the ACCOUNT_TYPE field when calling insert(userToken, ACCOUNT_TYPE, accountName, account).
Actually, looking back at my Glassware Review Request e-mail (which Google kindly updated for me today), I had not specified an "Account Type". But today they updated it to "lumilogger". Now, by inserting with this account type, the problem is solved.
The lessons learned are: 1. You need to specify an account type during your review request. 2. The account type you pass to insert() is what you specified in (1), not your APK package name (e.g. com.google.test, etc.).
Upvotes: 1