$authentication_bgl360->setAccessToken($userCurrentAccessToken[0]['access_token']);
        $response = $authentication_bgl360->getRefreshTokenData();
        if ($response['error'] == 'invalid_token') {
            echo "Refresh token is already used to retrieved new access token <br>";
        } else {
            // Update access token, refresh token, expired_at and updated_at
            $service_bgl360->updateAccessToken(array('access_token' => $response['access_token'], 'refresh_token' => $response['refresh_token'], 'expired_at' => $time->getAccessTokenExpireDateTime(), 'updated_at' => $time->getCurrentDateTime()));
        }
    } else {
        // Do nothing
        echo "Access Token is not expired <br>";
    }
} else {
    $accessToken = $authentication_bgl360->getAccessToken();
    /**
     * If retrieving access token got an error then should redirect the bgl360 application
     * I think this can be explore more later
     */
    if ($accessToken['error'] == 'invalid_grant') {
        echo "Invalid grant <br>";
        /**
         * has invalid response
         * then redirect to application authenticate the data
         */
        $authentication_bgl360->redirectUrlToAuthorizationPage();
    } else {
        echo "Insert new access token<br>";
        // If user don't have access token yet - so new access token must be inserted
        $service_bgl360->insertNewAccessToken(array('user_id' => $current_user->ID, 'access_token' => $accessToken['access_token'], 'token_type' => $accessToken['token_type'], 'refresh_token' => $accessToken['refresh_token'], 'expires_in' => $accessToken['expires_in'], 'scope' => $accessToken['scope'], 'expired_at' => $time->getAccessTokenExpireDateTime(), 'updated_at' => $time->getCurrentDateTime()));
    }
}