Google API Authentication for server(服务器的 Google API 身份验证)
问题描述
我一直在尝试让 Google 的日历 API 在 PHP 网络中运行申请,但我很难通过身份验证.
I've been trying to get Google's Calendar API working in a PHP web application, but I'm having a hard time getting authenticated.
我想要做的是允许用户与服务器已知的单个帐户的日历进行交互.
What I want to do is to allow users to interact with calendars of a single account known by the server.
OAuth 2.0 文档 中涵盖的每种类型的场景都谈论用户同意"这涉及登录表单和个人用户登录,但我希望服务器本身直接进行身份验证并为自己获取访问令牌.
Each type of scenario covered in the OAuth 2.0 docs talks about "user consent" which involves a login form and the individual user logging in, but I want the server itself to authenticate directly and obtain an access token for itself.
是否有 OAuth 的某些部分或我可以使用的替代机制来执行此操作?
Is there some part of OAuth or some alternative mechanism I can use to do this?
推荐答案
为此,您必须完成用户同意的步骤,然后将其提供给您的访问令牌复制到 PHP 代码中.
In order to do this, you must go through the steps for user consent and then copy the access tokens it gives you into the PHP code.
OAuth 通常的流程是这样的:
The usual procedure for OAuth is like this:
- 将用户发送到身份验证页面.
- 用户返回 $_GET['code']
- 将 $_GET['code'] 发送到 OAuth 服务器以获取令牌
- 在数据库中为用户存储令牌(或会话,如果它非常短暂)
但是当使用这样的单个日历进行操作时,您需要修改步骤 4.相反,您将令牌转储到屏幕并将其作为变量复制到您的 PHP 文件中,而不是将其放入数据库中.然后,当您将访问令牌传递给服务器时,您只需传递已知的静态令牌,而不是来自数据库/会话的动态令牌.
But when doing it with a single calendar like this, you modify step 4. Instead, you dump the token to screen and copy it into your PHP file as variables, instead of putting it in the database. Then when you go to pass the access token to the server, you just pass the known, static token rather than a dynamic token from the database / session.
这篇关于服务器的 Google API 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:服务器的 Google API 身份验证


- PHP - if 语句中的倒序 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01