@@ -386,15 +386,31 @@ lcb_RETRY_ACTION lcb_QUERY_HANDLE_::has_retriable_error(lcb_STATUS &rc)
386386 lcb_strerror_short (rc ), first_error .code , first_error .message .c_str ());
387387 return {1 , default_backoff };
388388 }
389- if (first_error .code == 13014 &&
390- LCBT_SETTING (instance_ , auth )-> mode () == LCBAUTH_MODE_DYNAMIC ) { // datastore.couchbase.insufficient_credentials
391- auto result = request_credentials (LCBAUTH_REASON_AUTHENTICATION_FAILURE );
392- bool credentials_found = result == LCBAUTH_RESULT_OK ;
393- lcb_log (LOGARGS (this , TRACE ),
394- LOGFMT "Invalidate credentials and retry request. creds: %s, rc: %s, code: %d, msg: %s" , LOGID (this ),
395- credentials_found ? "ok" : "not_found" , lcb_strerror_short (rc ), first_error .code ,
396- first_error .message .c_str ());
397- return {credentials_found , default_backoff };
389+ if (LCBT_SETTING (instance_ , auth )-> mode () == LCBAUTH_MODE_DYNAMIC ) {
390+ lcbauth_REASON reason_to_refresh_credentials {};
391+ switch (first_error .code ) {
392+ case 13014 : /* E_DATASTORE_INSUFFICIENT_CREDENTIALS */
393+ case 12037 : /* E_ACCESS_DENIED */
394+ reason_to_refresh_credentials = LCBAUTH_REASON_AUTHORIZATION_FAILURE ;
395+ break ;
396+
397+ case 2120 : /* E_ADMIN_AUTH */
398+ reason_to_refresh_credentials = LCBAUTH_REASON_AUTHENTICATION_FAILURE ;
399+ break ;
400+
401+ default :
402+ break ;
403+ }
404+
405+ if (reason_to_refresh_credentials ) {
406+ auto result = request_credentials (reason_to_refresh_credentials );
407+ bool credentials_found = result == LCBAUTH_RESULT_OK ;
408+ lcb_log (LOGARGS (this , TRACE ),
409+ LOGFMT "Invalidate credentials and retry request. creds: %s, rc: %s, code: %d, msg: %s" ,
410+ LOGID (this ), credentials_found ? "ok" : "not_found" , lcb_strerror_short (rc ), first_error .code ,
411+ first_error .message .c_str ());
412+ return {credentials_found , default_backoff };
413+ }
398414 }
399415 if (!first_error .message .empty ()) {
400416 for (const auto & magic_string : wtf_magic_strings ) {
0 commit comments