我正在尝试通过此链接在 GDK 中对用户进行身份验证: https://developers.google.com/glass/develop/gdk/authentication 它给出了 Java 示例,但我的网页使用 PHP。我知道我必须使用 https://github.com/google/google-api-php-client/blob/master/src/Google/Service/Mirror.php
我被服务授权页面调用 mirror.accounts.insert 卡住了。不确定如何实现服务授权页面。任何例子都会有很大帮助。
[已解决] 工作示例在这里:http://goo.gl/DVggO6
最佳答案
服务授权页面是用户在 MyGlass 中打开您的应用程序时打开的页面。您暂时存储与该请求一起发送的 userToken 查询参数(不要永久存储它),然后通过您运行的任何后端对用户进行身份验证。从那里您可能会请求他们的 Google 帐户的适当范围(在这种情况下,您需要 https://www.googleapis.com/auth/glass.thirdpartyauth 来插入该帐户)。完成后,您可以在 PHP 中正常创建镜像服务,然后使用帐户集合:
// $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);
请记住,只有在您的 APK 登陆 MyGlass 后(在审核过程中发生),您才能测试和使用此 API。如果您还没有了解身份验证的工作原理,我还推荐 Mirror API PHP Quickstart 作为起点。
关于php - 使用 PHP 的 Google Glass GDK 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23381012/