Skip to content

Commit

Permalink
Add usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ada-u committed Nov 24, 2017
1 parent b5d469f commit f00d511
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,44 @@ composer require chatwork/oauth2-chatwork

## Usage

### Get our consent page URL

```php
$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 access token

```php
$accessToken = $provider->getAccessToken((string) new AuthorizationCode(), [
'code' => $code
]);
```

### Refresh access token

```php
if ($accessToken->hasExpired()) {
$refreshedAccessToken = $provider->getAccessToken('refresh_token', [
'refresh_token' => $accessToken->getRefreshToken()
]);
}
```

### Get resource owner's profile

```php
$resource_owner = $provider->getResourceOwner($accessToken);
```

## Contributing

### Testing
Expand Down

0 comments on commit f00d511

Please sign in to comment.