programster/google-sso 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

programster/google-sso

最新稳定版本:0.0.2

Composer 安装命令:

composer require programster/google-sso

包简介

Apackage for integrating with Google SSO

README 文档

README

A package to make it easy to use Google SSO (OAuth 2 / OIDC), without minimal bloat and lots of flexibility.

This package makes use of the PSR-17 and PSR-18 interfaces, so this package should be able to work with any existing mechanism you use to send messages. If you are not sure what this means, then we would recommend that you just install the guzzlehttp/guzzle package, and follow the example in the README. If you cannot use Guzzle for whatever reason, then slim/psr7 is a good alternative.

Please be aware that this package requires the use of the $_SESSION superglobal

Usage

Installation

Install this in your codebase with composer like so:

composer require programster/google-sso

Example Code

There is an example codebase on GitHub that demonstrates using this package. Also, the following code snippet creates a Google SSO client and sends the user to Google to login.

<?php

require_once(__DIR__ . "/../vendor/autoload.php");

$googleSso = new GoogleSsoClient(
    $myGoogleClientId,
    $myGoogleClientSecret,
    $myGoogleSsoCallbackUrl = "https://localhost",
    new \GuzzleHttp\Psr7\HttpFactory(),
    new \GuzzleHttp\Client(),
);

if (isset($_GET['code']))
{
    // we are likely handling a user redirecting back here from having logged in with google.
    $userData = $googleSso->handleGoogleSsoLogin();
    print "Hello {$userData->getFullName()} with email address {$userData->getEmail()}";
}
else
{
    $googleSso->sendUserToGoogleLogin();
}

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-07