Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhndev/oauth-client
php oauth client (sdk)
https://github.com/mhndev/oauth-client
oauth-server oauth2 oauth2-client sdk-php
Last synced: 7 days ago
JSON representation
php oauth client (sdk)
- Host: GitHub
- URL: https://github.com/mhndev/oauth-client
- Owner: mhndev
- Created: 2017-04-16T12:07:40.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2018-10-07T15:32:34.000Z (about 6 years ago)
- Last Synced: 2024-03-17T22:10:55.326Z (8 months ago)
- Topics: oauth-server, oauth2, oauth2-client, sdk-php
- Language: PHP
- Size: 92.8 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Php OAuth Client (Sdk)
tokens table structure :
```
CREATE TABLE tokens (
client_id TEXT NOT NULL PRIMARY KEY,
client_secret TEXT NOT NULL,
credentials TEXT NOT NULL,
type TEXT NOT NULL,
expires_at datetime
);```
```php
connect()
);$guzzleClient = new \GuzzleHttp\Client();
$guzzleHandler = new \mhndev\oauthClient\handlers\GuzzleHandler(
$guzzleClient,
'http://dev.digipeyk.com:8030'
);// if you want to pass api ednpoints and you are not going to use default endpoints please pass the third argument as follow:
// consider you can just override as many endpoint as you want, and you are not forced to override all endpoints
$guzzleHandler = new \mhndev\oauthClient\handlers\GuzzleHandler(
$guzzleClient,
'http://dev.digipeyk.com:8030',
['removeIdentifier' => '/api/removeUserIdentifier']
);$oauth_client = new \mhndev\oauthClient\Client($guzzleHandler, $tokenRepository);
$token = $oauth_client->getClientToken($client_id, $client_secret);
//register endpoint
$user_register = $oauth_client->register(
'hamid',
'123456',
['email'=>'[email protected]'],
$token
);var_dump($user_register);
// whois endpoint
$user_whoIs = $oauth_client->getWhois(
'email',
'[email protected]',
$token
);var_dump($user_whoIs);
// get Token Info
$tokenValueObject = new \mhndev\valueObjects\implementations\Token(
$token->getCredentials(), $token->getType()
);$tokenInfo = $oauth_client->getTokenInfo($tokenValueObject);
var_dump($tokenInfo);
echo '
';// now using mock handler instead as handler
$mockHandler = new \mhndev\oauthClient\handlers\MockHandler();
$oauth_client2 = new \mhndev\oauthClient\Client($mockHandler, $tokenRepository);
$tokenFromMock = $oauth_client2->getClientToken('wefwergderf', 'werwrgfer');
var_dump($tokenFromMock);
$result = $oauth_client2->register(
'majid',
'123456',
['email' => '[email protected]'],
new \mhndev\oauthClient\entity\common\Token(
'Bearer',
'34r3t354t54tr',
$client_id,
$client_secret
)
);var_dump($result);
```
todo :
toArray for oauth objects