most-significant-bit / oauth2-client
OAuth 2.0 Client. Implement RFC 6749.
Installs: 3 305
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=5.3.3
- beberlei/assert: ~2.3
- myclabs/php-enum: ~1.3
- php-curl-class/php-curl-class: ~3.5.0
- zendframework/zend-json: ^2.2
- zendframework/zend-stdlib: ^2.2
- zendframework/zend-uri: ^2.2
Requires (Dev)
- php: >=5.3.3
- coduo/tutu: dev-master
- coduo/tutu-faker-extension: dev-master
- coduo/tutu-twig-extension: dev-master
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~2.2
- symfony/process: ~2.6
This package is not auto-updated.
Last update: 2024-12-27 22:45:41 UTC
README
Usage
use MostSignificantBit\OAuth2\Client\Client as OAuth2Client; use MostSignificantBit\OAuth2\Client\Config\Config; use MostSignificantBit\OAuth2\Client\AccessToken\SuccessfulResponse as AccessTokenSuccessfulResponse; use MostSignificantBit\OAuth2\Client\Grant\ResourceOwnerPasswordCredentials\AccessTokenRequest; use MostSignificantBit\OAuth2\Client\Grant\ResourceOwnerPasswordCredentials\ResourceOwnerPasswordCredentialsGrant; use MostSignificantBit\OAuth2\Client\Parameter\AccessToken; use MostSignificantBit\OAuth2\Client\Parameter\ExpiresIn; use MostSignificantBit\OAuth2\Client\Parameter\Password; use MostSignificantBit\OAuth2\Client\Parameter\RefreshToken; use MostSignificantBit\OAuth2\Client\Parameter\TokenType; use MostSignificantBit\OAuth2\Client\Parameter\Username; $config = new Config(array( 'endpoint' => array( 'token_endpoint_uri' => 'http://127.0.0.1:8000/oauth2/token', ), 'client' => array( 'credentials' => array( 'client_id' => 's6BhdRkqt3', 'client_secret' => '7Fjfp0ZBr1KtDRbnfVdmIw', ), ), )); $oauth2Client = new OAuth2Client($config); $accessTokenRequest = new AccessTokenRequest(new Username('johndoe'), new Password('A3ddj3w')); $grant = new ResourceOwnerPasswordCredentialsGrant($accessTokenRequest); try { $accessTokenResponse = $oauth2Client->obtainAccessToken($grant); } catch (TokenException $exception) { //log exception }
Contribution
Testing
OAuth2 Client library has wrote unit and integration tests. We use phpunit for both of them.
Run all tests
vendor/bin/phpunit
Run only unit tests
vendor/bin/phpunit --group unit
Run only integration tests
vendor/bin/phpunit --group integration