使用PHP的Google Glass GDK身份验证 [英] Google Glass GDK Authentication using PHP

查看:83
本文介绍了使用PHP的Google Glass GDK身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我对调用mirror.accounts.insert的服务身份验证页面感到困惑.不确定如何实现服务身份验证页面.任何例子都会有很大帮助.

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.

[已解决]此处为工作示例: http://goo.gl/DVggO6

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

推荐答案

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

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);

请记住,您只能在APK落在MyGlass上(在审核过程中发生)之后测试和使用此API.我还建议您以Mirror API PHP快速入门作为起点,以了解身份验证的工作原理(如果您还没有这样做的话).

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.

这篇关于使用PHP的Google Glass GDK身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆