Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/contamobi/pmobi-oauth2-php-client
https://github.com/contamobi/pmobi-oauth2-php-client
guzzlehttp middleware oauth2-client php71
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/contamobi/pmobi-oauth2-php-client
- Owner: contamobi
- License: mit
- Created: 2018-04-30T18:56:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-02T13:37:50.000Z (over 6 years ago)
- Last Synced: 2024-10-01T18:10:08.552Z (about 2 months ago)
- Topics: guzzlehttp, middleware, oauth2-client, php71
- Language: PHP
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### pague.MOBI Oauth2 Middleware
This is GuzzleHttp Middleware for pague.MOBI Oauth2. Based on [Guzzle OAuth 2.0 Subscriber](https://github.com/kamermans/guzzle-oauth2-subscriber).
##### Usage
With classes
```php
"https://anything.p.mobi/oauth2/token",
]);$authConfig = [
"client_id" => "your-client-id",
"client_secret" => "your-client-secret",
"username" => "your-username",
"password" => "your-password",
];$grantType = new PmobiCredentials($authClient, $authConfig);
$oauth = new OAuth2Middleware($grantType);
$stack = HandlerStack::create();
$stack->push($oauth);$client = new Client([
'handler' => $stack,
'auth' => 'oauth',
]);$response = $client->request(
'get',
'https://anything.p.mobi/anywhere',
[
'headers' => [
'Content-Type' => 'application/json',
],
]
);var_dump($response->getBody()->getContents());
```With Pmobi Middleware
```php
"https://anything.p.mobi/oauth2/token",
"client_id" => "your-client-id",
"client_secret" => "your-client-secret",
"username" => "your-username",
"password" => "your-password",
];// Optional
$authConfig["token_filepath"] = "/tmp/access_token.json";$stack = PmobiOauth2Middleware::createFromConfig($reauthConfig);
$client = new Client([
'handler' => $stack,
'auth' => 'oauth',
]);$response = $client->request(
'get',
'https://anything.p.mobi/anywhere',
[
'headers' => [
'Content-Type' => 'application/json',
],
]
);var_dump($response->getBody()->getContents());
```Token persistence
```php
setTokenPersistence($tokenPersistence);```
More information about persistence in [https://github.com/kamermans/guzzle-oauth2-subscriber#access-token-persistence](https://github.com/kamermans/guzzle-oauth2-subscriber#access-token-persistence).