https://github.com/dmt-software/oauth2-trustpilot
https://github.com/dmt-software/oauth2-trustpilot
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dmt-software/oauth2-trustpilot
- Owner: dmt-software
- License: mit
- Created: 2022-04-11T20:51:00.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-13T06:10:04.000Z (about 4 years ago)
- Last Synced: 2025-11-09T17:17:46.752Z (6 months ago)
- Language: PHP
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Trustpilot Provider for OAuth 2.0 Client
## Install
`composer require dmt-software/oauth2-trustpilot`
## Usage
```php
use DMT\OAuth2\Client\Provider\Trustpilot;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
$provider = new Trustpilot([
'clientId' => '{ your_client_id }',
'clientSecret' => '{ your_client_secret }',
]);
try {
$accessToken = $provider->getAccessToken(
'password', [
'username' => '{ your_username }',
'password' => '{ your_password }'
]
);
} catch (IdentityProviderException $exception) {
if ($exception->getCode() === 401) {
// token is expired
}
if ($exception->getCode() === 429) {
// too many requests
}
}
```
> see more examples on [league/oauth2-client](https://oauth2-client.thephpleague.com/usage/)
## Error handling
Unfortunately the response body in case of an error is not consistent. To better understand the reason a request is
failed call the `IdentityProviderException::getResponseBody` method.