Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Guzzleのoauth2のプラグインを使わずに書いたやつ。
<?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