定制 rogerthomas84/ohgoo 二次开发

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

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

rogerthomas84/ohgoo

Composer 安装命令:

composer require rogerthomas84/ohgoo

包简介

OhGoo is a simple OAuth library for authenticating Google users with your application.

README 文档

README

OhGoo is a simple OAuth library for authenticating Google users with your application.

Configuration

Configuration is a singleton. Ultimately you need to set up a 'Web Application' credential in a Google Cloud Console project in order to get the details required for the config object.

<?php
\OhGoo\OhGooConfig::getInstance()->setClientId(
    'xxxx-xxxx.apps.googleusercontent.com'
)->setClientSecret(
    'xxxxxxxx'
)->setRedirectUri(
    'http://mydomain.tld/my-path'
);

Authenticating

<?php
if ($_GET['code']) {
    try {
        $data = \OhGoo\OhGooService::getAccessTokenFromCode($_GET['code']);
        // If you have a refresh token already for a user, call the line below instead:
        // $data = \OhGoo\OhGooService::getAccessTokenFromRefreshToken($theRefreshToken)
        if ($data instanceof \OhGoo\Dto\OauthCredentialsDto) {
            $userDto = \OhGoo\OhGooService::getGoogleUser($data);
            var_dump($userDto);
            exit;
        }
        echo 'Logging in via Google failed.';
        exit;

    } catch(Exception $e) {
        echo sprintf(
            'We experienced an error authenticating you via Google. Message: %s',
            $e->getMessage()
        );
        exit;
    }
}

header("Location: " . \OhGoo\OhGooService::getLoginUrl(
    \OhGoo\OhGooService::ACCESS_TYPE_OFFLINE // OR \OhGoo\OhGooService::ACCESS_TYPE_ONLINE
));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固