chatwork / oauth2-chatwork
ChatWork OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Installs: 1 398
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 69
Forks: 4
Open Issues: 3
Requires
- php: ^7.0 || ^8.0
- league/oauth2-client: ^2.7.0
Requires (Dev)
- phpunit/phpunit: ^6.0 || ^9.0
This package is not auto-updated.
Last update: 2024-09-21 05:33:44 UTC
README
Installation
composer require chatwork/oauth2-chatwork
Usage
Get our consent page URL
$provider = new ChatWorkProvider( getenv('OAUTH2_CLIENT_ID'), getenv('OAUTH2_CLIENT_SECRET'), getenv('OAUTH2_REDIRECT_URI') ); $url = $provider->getAuthorizationUrl([ 'scope' => ['users.all:read', 'rooms.all:read_write'] ]);
Get an access token
$accessToken = $provider->getAccessToken((string) new AuthorizationCode(), [ 'code' => $code ]);
Refresh a token
if ($accessToken->hasExpired()) { $refreshedAccessToken = $provider->getAccessToken((string) new RefreshToken(), [ 'refresh_token' => $accessToken->getRefreshToken() ]); }
Get resource owner's profile
$resource_owner = $provider->getResourceOwner($accessToken);
Example
An example of ChatWork OAuth2 client
ChatWork OAuth2.0 document
Blog
チャットワークのOAuth2のクライアントをPHPで簡単に実装するためのライブラリを紹介
Contributing
Testing
$ make test
License
The MIT License (MIT).