Created
April 2, 2018 22:33
-
-
Save noriyukitakei/1656831dedd1b1c85895fb42e5f2126a to your computer and use it in GitHub Desktop.
OAuthプロバイダーライブラリ共通処理
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// データベースの接続情報です。 | |
$dsn = 'mysql:dbname=provider;host=localhost'; | |
$username = 'root'; | |
$password = 'password'; | |
// エラーログのレベルを定義します。全てのエラーログを出力しているようにしてます。 | |
ini_set('display_errors',1);error_reporting(E_ALL); | |
// OAuthプロバイダーのライブラリを読み込んでいます。 | |
require_once('vendor/bshaffer/oauth2-server-php/src/OAuth2/Autoloader.php'); | |
OAuth2\Autoloader::register(); | |
// OAuthの情報を保存するストレージオブジェクトを作成します。 | |
$storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password)); | |
// OAuthプロバイダーに必要ないろんな処理を行うためのインスタンスを作成します。 | |
$server = new OAuth2\Server($storage); | |
// Authorization Codeを使うために必要な設定です。 | |
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment