public String getAuthenticationToken(ContainerRequest request) {

        // Give priority to token within HTTP header
        String token = request.getHeaderString(TOKEN_HEADER_NAME);
        if (token != null && !token.isEmpty())
            return token;

        // If no token was provided via HTTP headers, fall back to using
        // query parameters
        token = request.getUriInfo().getQueryParameters().getFirst(TOKEN_PARAMETER_NAME);
        if (token != null && !token.isEmpty())
            return token;

        return null;

    }
Returns the authentication token sent within the given request, if
present, or null if otherwise. Authentication tokens may be sent via
the "Guacamole-Token" header or the "token" query parameter. If both
the header and a parameter are used, the header is given priority.

@param request
    The HTTP request to retrieve the authentication token from.

@return
    The authentication token within the given request, or null if no
    token is present.
guacamole/src/main/java/org/apache/guacamole/rest/auth/AuthenticationService.java