承接 indibeast/oauth2-human 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

indibeast/oauth2-human

Composer 安装命令:

composer require indibeast/oauth2-human

包简介

Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client

README 文档

README

Build Status

This package provides Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Usage

Authorization Code Flow

$provider = new \Human\OAuth2\Client\Provider\Human([
    'clientId'      => 'XXXXXXXX',
    'clientSecret'  => 'XXXXXXXX',
    'redirectUri'   => 'https://your-registered-redirect-uri/',
    'account'       => 'XXXXX'

]);

if (!isset($_GET['code'])) {

    $authurl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

 } elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])){

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

 } else {

     $token = $provider->getAccessToken('authorization_code', [
                 'code' => $_GET['code']
     ]);

     try {

        $client = new Client($token);
        $user   = $client->getResourceOwner();
        echo $user->getFirstName();

     } catch (Exception $e) {

        echo "Oops!..."
     }

 }

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-23