Created
November 1, 2014 16:51
-
-
Save mapyo/354fbb5c7c6a50c5574d to your computer and use it in GitHub Desktop.
Guzzleのoauth2のプラグインを使わずに書いたやつ。
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 | |
require 'vendor/autoload.php'; | |
use Guzzle\Http\Client; | |
$settings = parse_ini_file('config/settings.ini'); | |
# Resource Owner Password Credentials Grant | |
$client = new Client($settings['base_url']); | |
$params = array( | |
'grant_type' => 'password', | |
'username' => $settings['username'], | |
'password' => $settings['password'], | |
'scope' => $settings['scope'], // Optional. | |
); | |
$data = $client->post('/oauth/token', array(), $params)->send()->json(); | |
var_dump($data['access_token']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment