Authenticating Google Glass GDK using PHP

I am trying to follow this link to authenticate the user in the GDK: https://developers.google.com/glass/develop/gdk/authentication It gives an example in Java, but uses PHP in my webpage. I know that I need to use https://github.com/google/google-api-php-client/blob/master/src/Google/Service/Mirror.php

I am stuck with the auth service by making a call to mirror.accounts.insert. You do not know how to implement the service authorization page. Any example would be a big help.

[SOLVED] A working example here: http://goo.gl/DVggO6

+4
source share
1 answer

The service authorization page is the page that opens when this user includes your application in MyGlass. You temporarily save the userToken request parameter sent with this request (do not save it forever), and then authenticate the user by which backend you are using. From there, you will probably request the correct scope for your Google account (in this case you need to https://www.googleapis.com/auth/glass.thirdpartyauth to insert the account). After that, you can create your mirror service as usual in PHP, and then use the account collection:

// $myClient would contain the typical Google_Client() setup
// See PHP quickstart for example
$myMirrorService = new Google_Service_Mirror($myClient);

// Set your inputs to insert() as needed
$accounts = $myMirrorService->accounts->insert($userToken, $accountType, $accountName, $postBody);

, API , APK MyGlass ( ). PHP- Mirror API PHP , , , .

+1

Source: https://habr.com/ru/post/1538676/


All Articles