steein/oauth2-steein
Composer 安装命令:
composer require steein/oauth2-steein
包简介
Steein OAuth 2.0 Client Provider for The PHP
README 文档
README
This package provides support for Steein OAuth 2.0 for the OAuth 2.0 PHP client.
Requirements
The following versions of PHP are supported.
- PHP >= 5.6
- HHVM
Installation
To install, use composer:
composer require steein/oauth2-steein
Usage
Usage is the same as The OAuth client, using \Steein\OAuth2\Client\Steein as the provider.
Authorization Code Flow
$provider = new \Steein\OAuth2\Client\Steein([ 'clientId' => '{client_id}', 'clientSecret' => '{client_secret}', 'redirectUrl' => '{callback_url}', 'ApiVersion' => '2.0', ]); if (!isset($_GET['code'])) { // Если у нас нет кода авторизации, $authUrl = $provider->getAuthorizationUrl(); echo '<a href="'.$authUrl.'">Авторизация через Steein!</a>'; } else { // Попробуйте получить токен доступ (используя грант кода авторизации) $token = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'], 'grant_type' => 'authorization_code' ]); try { // Теперь у нас есть токен доступ, давайте теперь узнаем подробности пользователя. $user = $provider->getResourceOwner($token); // $user->get...(); echo $user->getDisplayName().'<br />'; echo $user->getAvatar().'<br />'; } catch (Exception $e) { exit('Что та пошло не так'); } }
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-18