barnabynorman/google-auth-wrapper
最新稳定版本:1.0.4
Composer 安装命令:
composer require barnabynorman/google-auth-wrapper
包简介
Wrapper to simplify use of Google PHP Client Library
关键字:
README 文档
README
Uses google-api-php-client and simplifies configuration / use
Getting started with composer
"require": {
"barnabynorman/google-auth-wrapper": "^1.0"
}
Make sure to include the autoloader:
require_once '/path/to/your-project/vendor/autoload.php';
Register with google at: https://github.com/googleapis/google-api-php-client/blob/main/docs/README.md
Note your:
- Client ID
- Client Secret
Basic use
<?php require_once 'vendor/autoload.php'; // This is your landing place $redirectUrl = 'https://research.familynorman.org.uk'; $clientId = 'your google client ID'; $clientSecret = 'your google client Secret'; $auth = new GoogleAuthWrapper($clientId, $clientSecret, $redirectUrl); $authResponse = $auth->doLogin(); if (is_array($authResponse)) { // Redirect response as part of login processs header('Location: ' . $authResponse['redirect']); } elseif ($authResponse !== false) { // Authenticated with google // Test the email address switch ($authResponse) { case 'bob@test.com': // Content here break; case 'jane@test.com': // Content here break; case 'jane@test.com': // Content here break; case 'mary@test.com': // Content here break; default: // Show login page or 404 etc } }
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-11