定制 barnabynorman/google-auth-wrapper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-11