code: @Override
      public void generateError(String response) {
          final String errorInString = extractParameter(response, ERROR_REGEX_PATTERN, true);
          final String errorDescription = extractParameter(response, ERROR_DESCRIPTION_REGEX_PATTERN, false);
  
          OAuth2Error errorCode;
          try {
              errorCode = OAuth2Error.parseFrom(errorInString);
          } catch (IllegalArgumentException iaE) {
              //non oauth standard error code
              errorCode = null;
          }
  
          throw new OAuth2AccessTokenErrorResponse(errorCode, errorDescription, null, response);
      }
docs: Related documentation: https://dev.fitbit.com/build/reference/web-api/oauth2/