Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 94f0803

Browse files
committed
Re-commit whole guzzle folder.
1 parent a1f6ce4 commit 94f0803

File tree

101 files changed

+9147
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+9147
-0
lines changed

core/src/core/classes/guzzle/composer.lock

Lines changed: 590 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/bin/
2+
/build/
3+
/vendor/
4+
phpunit.xml
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tools:
2+
external_code_coverage: true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
language: php
2+
3+
sudo: false
4+
5+
php:
6+
- 5.6
7+
- 5.5
8+
- 5.4
9+
- 7.0
10+
- hhvm
11+
12+
cache:
13+
directories:
14+
- $HOME/.composer/cache
15+
16+
install:
17+
- composer install --prefer-dist --no-interaction
18+
19+
before_script:
20+
- mkdir -p build/logs
21+
22+
script:
23+
- ./bin/phpunit --verbose --coverage-clover build/logs/clover.xml
24+
25+
after_script:
26+
- wget https://scrutinizer-ci.com/ocular.phar -t 3
27+
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013 Bojan Zivanovic
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
guzzle-oauth2-plugin
2+
====================
3+
4+
Provides an OAuth2 plugin (subscriber) for [Guzzle](http://guzzlephp.org/).
5+
6+
[![Build Status](https://travis-ci.org/commerceguys/guzzle-oauth2-plugin.svg)](https://travis-ci.org/commerceguys/guzzle-oauth2-plugin)
7+
[![Code Coverage](https://scrutinizer-ci.com/g/commerceguys/guzzle-oauth2-plugin/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/commerceguys/guzzle-oauth2-plugin/?branch=master)
8+
9+
Version 2.x (on the `master` branch) is intended for Guzzle 5:
10+
```json
11+
"commerceguys/guzzle-oauth2-plugin": "~2.0"
12+
```
13+
14+
Guzzle 3 compatibility continues in the [`1.0`](https://github.com/commerceguys/guzzle-oauth2-plugin/tree/1.0) branch:
15+
```json
16+
"commerceguys/guzzle-oauth2-plugin": "~1.0"
17+
```
18+
19+
## Features
20+
21+
- Acquires access tokens via one of the supported grant types (code, client credentials,
22+
user credentials, refresh token). Or you can set an access token yourself.
23+
- Supports refresh tokens (stores them and uses them to get new access tokens).
24+
- Handles token expiration (acquires new tokens and retries failed requests).
25+
26+
## Running the tests
27+
28+
First make sure you have all the dependencies in place by running `composer install --prefer-dist`, then simply run `./bin/phpunit`.
29+
30+
## Example
31+
```php
32+
use GuzzleHttp\Client;
33+
use CommerceGuys\Guzzle\Oauth2\GrantType\RefreshToken;
34+
use CommerceGuys\Guzzle\Oauth2\GrantType\PasswordCredentials;
35+
use CommerceGuys\Guzzle\Oauth2\Oauth2Subscriber;
36+
37+
$base_url = 'https://example.com';
38+
39+
$oauth2Client = new Client(['base_url' => $base_url]);
40+
41+
$config = [
42+
'username' => '[email protected]',
43+
'password' => 'test password',
44+
'client_id' => 'test-client',
45+
'scope' => 'administration',
46+
];
47+
48+
$token = new PasswordCredentials($oauth2Client, $config);
49+
$refreshToken = new RefreshToken($oauth2Client, $config);
50+
51+
$oauth2 = new Oauth2Subscriber($token, $refreshToken);
52+
53+
$client = new Client([
54+
'defaults' => [
55+
'auth' => 'oauth2',
56+
'subscribers' => [$oauth2],
57+
],
58+
]);
59+
60+
$response = $client->get('https://example.com/api/user/me');
61+
62+
print_r($response->json());
63+
64+
// Use $oauth2->getAccessToken(); and $oauth2->getRefreshToken() to get tokens
65+
// that can be persisted for subsequent requests.
66+
67+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "commerceguys/guzzle-oauth2-plugin",
3+
"description": "An OAuth2 plugin (subscriber) for Guzzle",
4+
"license": "MIT",
5+
"require": {
6+
"guzzlehttp/guzzle": "~5.0",
7+
"firebase/php-jwt": "~2.0"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"CommerceGuys\\Guzzle\\Oauth2\\": "src"
12+
}
13+
},
14+
"require-dev": {
15+
"phpunit/phpunit": "~4.5"
16+
},
17+
"autoload-dev": {
18+
"psr-4": {
19+
"CommerceGuys\\Guzzle\\Oauth2\\Tests\\": "tests"
20+
}
21+
},
22+
"authors": [
23+
{
24+
"name": "Bojan Zivanovic"
25+
},
26+
{
27+
"name": "Damien Tournoud"
28+
},
29+
{
30+
"name": "Patrick Dawkins"
31+
}
32+
],
33+
"config": {
34+
"bin-dir": "bin"
35+
}
36+
}

0 commit comments

Comments
 (0)