code: protected String getSpace(Request req) {
          String spaceToken = req.headers(SPACE_TOKEN_HEADER);
          if (StringUtils.isBlank(spaceToken)) {
              throw new MissingSpaceTokenException("Missing header '" + SPACE_TOKEN_HEADER + "'.");
          }
  
          String space = this.spacesService.getSpaceForAuthenticationToken(spaceToken);
          if (space == null) {
              throw new InvalidSpaceTokenException(spaceToken);
          }
  
          return space;
      }
docs: Extract spaceToken from request headers.
  
  @param req - Request to extract spaceToken from.
  @return Extracted spaceToken.
  @throws MissingSpaceTokenException If the spaceToken Header is missing in the request.
  @throws InvalidSpaceTokenException If no space is configured for the supplied spaceToken.