So im accessing some data via an oAuth2 access token and i want to catch the expiration of the access token. When it expires i catch the error code and refresh the token. After that i call the function recursivly. If the refresh token for some reason does not work, it would loop infinitly. How do i jump out of this loop after 1 try?
function companyList($page){
//send http-request
if($obj['errors']['status'] == '401'){
Authentication::refreshToken();
companyList($page);
}
}