Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Resource Owner Password Credentials Grant を Guzzle3を使って書いたサンプルです。
require 'vendor/autoload.php';
use Guzzle\Http\Client;
use CommerceGuys\Guzzle\Plugin\Oauth2\GrantType\PasswordCredentials;
$settings = parse_ini_file('config/settings.ini');
# Resource Owner Password Credentials Grant
$oauth2Client = new Client($settings['base_url'] . '/oauth/token');
$config = array(
'username' => $settings['username'],
'password' => $settings['password'],
'client_id' => $settings['client_id'],
'client_secret' => $settings['client_secret'],
// 'client_id' => null, # null でもよい
// 'client_secret' => null, # null でもよい
'scope' => $settings['scope'], // Optional.
$grantType = new PasswordCredentials($oauth2Client, $config);
$tokenData = $grantType->getTokenData();

This comment has been minimized.

Copy link
Owner Author

@mapyo mapyo commented Nov 1, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment