Skip to content

Commit

Permalink
Merge pull request #235 from roel-de-vries/fix-ah-api-again
Browse files Browse the repository at this point in the history
Fix AH invalid refresh token handling
  • Loading branch information
Forceu authored Jan 31, 2024
2 parents 3cc5340 + e375531 commit a6bbe5a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions incl/lookupProviders/ProviderAlbertHeijn.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,15 @@ private function newAuthToken(): ?array {
private function refreshToken(string $refreshToken): ?array {
$json = '{"clientId": "appie", "refreshToken": "' . $refreshToken . '"}';
$url = "https://api.ah.nl/mobile-auth/v1/auth/token/refresh";
$authkeyResponse = null;

try {
$authkeyResponse = $this->execute($url, METHOD_POST, null, self::USER_AGENT, null, true, $json);
}
catch(Exception $e) {
$authkeyResponse = $this->execute($url, METHOD_POST, null, self::USER_AGENT, null, true, $json);

if ($authkeyResponse == null) {
$authkeyResponse = $this->newAuthToken();
}
if (!isset($authkeyResponse["access_token"]))

if (!isset($authkeyResponse["access_token"])) {
return null;
}

return $authkeyResponse;
}
Expand Down

0 comments on commit a6bbe5a

Please sign in to comment.