devdot/churchtools-oauth2-client 问题修复 & 功能扩展

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

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

devdot/churchtools-oauth2-client

最新稳定版本:v1.0.0

Composer 安装命令:

composer require devdot/churchtools-oauth2-client

包简介

OAuth2 Client for ChurchTools

README 文档

README

OAuth2 Client for ChurchTools

Installation

composer require devdot/churchtools-oauth2-client

Basic Usage

use Devdot\ChurchTools\OAuth2\Client\Provider\ChurchTools;

$provider = new ChurchTools([
    'url' => 'https://YOUR-INSTANCE.church.tools',
    'clientId' => 'Client-ID-From-OAUTH2-Setup',
    'redirectUri' => 'The Redirect Uri you provided to CT',
]);

$code = $_GET['code'] ?? null;

if ($code === null) {
    // redirect to OAuth Server
    $redirect = $provider->getAuthorizationUrl();

    header('Location: ' . $redirect);
    exit;
}
else {
    try {
        // attempt to get access tokens
        $tokens = $provider->getAccessTokenFromCode($code);

        // get the user that was authenticated
        $oauthUser = $provider->getResourceOwner($tokens);

        // store to session or use for further validation
        // ...
    }
    catch (League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
        if ($e->getMessage() === 'invalid_grant') {
            // code is not valid anymore, try again
            header('Location: ' . $provider->getAuthorizationUrl());
            exit;
        }
        
        throw $e;
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-02