Google Glass GDK Authentication using PHP

天涯浪子 提交于 2019-12-05 16:27:29

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.

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