Skip to content

Commit c0e0d63

Browse files
committed
Only trigger convertkit_api_access_token_invalid when an invalid access token is used
Otherwise a 401 for e.g. member content will result in the access token wrongly being removed, when it’s a valid access token.
1 parent 3fc3892 commit c0e0d63

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/class-convertkit-api-v4.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ public function request( $endpoint, $method = 'get', $params = array(), $retry_i
14751475
// Attempt the request again, now we have a new access token.
14761476
return $this->request( $endpoint, $method, $params, false );
14771477

1478-
default:
1478+
case 'The access token is invalid':
14791479
$error = new WP_Error(
14801480
'convertkit_api_error',
14811481
$error,
@@ -1494,6 +1494,13 @@ public function request( $endpoint, $method = 'get', $params = array(), $retry_i
14941494

14951495
// Return error.
14961496
return $error;
1497+
1498+
default:
1499+
return new WP_Error(
1500+
'convertkit_api_error',
1501+
$error,
1502+
$http_response_code
1503+
);
14971504
}
14981505

14991506
case 429:

0 commit comments

Comments
 (0)