Skip to content

OData. Can't set odata csrf token #1223

Open
@tbw777

Description

@tbw777

Version 2.3.7 Odata sap.

Can't set odata csrf token and cookies fore generated service.
Not found answer for a long time at internet or code.

For csrf i also tried (without result at sniffer):

        ClientResource resource = service.createResource("/LoQmHeaderSet");

        resource.setAttribute("X-CSRF-Token", "Fetch");

        attributes.put("X-CSRF-Token", "Fetch");
        resource.getRequest().setAttributes(attributes);

        resource.getRequest().getAttributes().put("X-CSRF-Token", "Fetch");

        Series<Header> headers = (Series<Header>) resource.getRequestAttributes().get(
                "org.restlet.http.headers");
        if(headers == null) {
            headers = new Series<>(Header.class);
        }
        headers.add("X-CSRF-Token", "Fetch");

Also restlet always request root xml without authorization. How to fix this?

But i want it to set at service contruction (with "X-Csrf-Token: Fetch") and cookies too.

I have 403 error without token and(!) cookie.

UPD. Token can changed unpredictably for different urls

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions