Google Glass GDK Authentication using PHP

末鹿安然 提交于 2019-12-22 09:07:46

问题


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

I am stuck with service auth page making call to mirror.accounts.insert. Not sure how to implement the service auth page. Any example would be great help.

[SOLVED] Working example is here: http://goo.gl/DVggO6


回答1:


The service auth page is the page that is opened when that user turns on your application in MyGlass. You temporarily store the userToken query param sent with that request (don't permanently store it), and then authenticate the user by whichever backend you have running. From there you then likely request the proper scope for their Google account (in this case, you need https://www.googleapis.com/auth/glass.thirdpartyauth to insert the account). Once that's done, you can create your Mirror Service as normal in PHP and then use the Accounts 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);

Keep in mind, you can only test and use this API after your APK lands on MyGlass (which happens during the review process). I would also recommend the Mirror API PHP Quickstart as a start point to understand how the authentication works if you have not done so already.



来源:https://stackoverflow.com/questions/23381012/google-glass-gdk-authentication-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!