Skip to content

Instantly share code, notes, and snippets.

@mapyo
Created November 1, 2014 16:51
Show Gist options
  • Save mapyo/354fbb5c7c6a50c5574d to your computer and use it in GitHub Desktop.
Save mapyo/354fbb5c7c6a50c5574d to your computer and use it in GitHub Desktop.
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