【问题标题】:Google Glass GDK Authentication using PHP使用 PHP 的 Google Glass GDK 身份验证
【发布时间】:2014-04-30 06:21:41
【问题描述】:

我正在尝试通过此链接在 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

【问题讨论】:

  • 您声明您正在尝试使用“GDK”进行身份验证,但您谈论的是 Web 服务器(通常与镜像 API 身份验证一起使用)。您能否重申或澄清您的要求。

标签: php google-glass google-mirror-api google-gdk


【解决方案1】:

服务认证页面是用户在 MyGlass 中打开您的应用程序时打开的页面。您临时存储与该请求一起发送的 userToken 查询参数(不要永久存储它),然后通过您运行的任何后端对用户进行身份验证。然后,您可能会从那里为他们的 Google 帐户请求适当的范围(在这种情况下,您需要 https://www.googleapis.com/auth/glass.thirdpartyauth 来插入帐户)。完成后,您可以像往常一样在 PHP 中创建镜像服务,然后使用 Accounts 集合:

// $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 快速入门作为了解身份验证工作原理的起点。

【讨论】:

  • 好吧。谢谢。那么是否可以使用 Google OAuth 服务完成初始身份验证?
  • 另外,我无法找到任何关于在 postbody 参数中包含什么 authtoken 的信息。任何帮助表示赞赏。
  • 您能否提供Google_Client() 设置和Service Account 的示例?这是我正在使用的代码pastebin.com/2GW6A5pN
  • 我收到错误:app/Google/Http/REST.php 中的权限不足'。我认为这是由于向服务添加范围的方式不正确。我正在使用这种方法: $key = file_get_contents($key_file_location); $cred = new Google_Auth_AssertionCredentials($email, 'googleapis.com/auth/glass.thirdpartyauth', $key); $client->setAssertionCredentials($cred);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-19
  • 1970-01-01
  • 2020-07-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多