Skip to content

Commit

Permalink
Patch/1.0.1 (#3)
Browse files Browse the repository at this point in the history
* Pass Twitter error description correctly to class

Apparently twitter returns the error description in the key `error_description`, not in `description`

* Update README and CHANGELOG

Co-authored-by: Niklas <[email protected]>
  • Loading branch information
oddevan and niklaswa authored Aug 16, 2022
1 parent 2c3df3f commit b8601d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog #

This project uses [semantic versioning](https://semver.org).

## Version 1

### 1.0.0

- Initial release

### 1.0.1

- Correctly return error description ([PR #2](https://github.com/smolblog/oauth2-twitter/pull/2))
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ if (!isset($_GET['code'])) {

// Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code'],
'code_verifier' => $_SESSION['oauth2verifier'],
'code' => $_GET['code'],
'code_verifier' => $_SESSION['oauth2verifier'],
]);

// Optional: Now you have a token you can look up a users profile data
Expand All @@ -97,15 +97,19 @@ if (!isset($_GET['code'])) {
print_r($e);
echo '</pre>';

// Failed to get user details
exit('Oh dear...');
// Failed to get user details
exit('Oh dear...');
}

// Use this to interact with an API on the users behalf
echo $token->getToken();
}
```

## Changelog

See `CHANGELOG.md`

## Credits

- [Evan Hildreth](https://github.com/oddevan)
Expand Down
2 changes: 1 addition & 1 deletion src/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function checkResponse(ResponseInterface $response, $data): void
return;
}

$error = $data['description'] ?? '';
$error = $data['error_description'] ?? '';
$code = $data['code'] ?? $response->getStatusCode();

throw new IdentityProviderException($error, $code, $data);
Expand Down

0 comments on commit b8601d9

Please sign in to comment.