Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateless authorization on preload requests #117

Open
SherinBloemendaal opened this issue Oct 3, 2023 · 0 comments
Open

Stateless authorization on preload requests #117

SherinBloemendaal opened this issue Oct 3, 2023 · 0 comments

Comments

@SherinBloemendaal
Copy link

SherinBloemendaal commented Oct 3, 2023

Hello,

I could not find any documentation about stateless authorization, for example when using the lexik-jwt-authentication-bundle in combination with API-platform. We are getting a 401 Unauthorized on the preload responses, is this expected behaviour or not?

My code:

const bookResp = await fetch("/api/books", {
        "headers": {
            "accept": "application/ld+json",
            "accept-language": "en,nl;q=0.9",
            "authorization": "Bearer " + token,
            "preload": "\"/hydra:member/*/author\"",
            "fields": "\"/hydra:member/*/author/name\"",
        },
        "referrer": "https://localhost/api",
        "referrerPolicy": "strict-origin-when-cross-origin",
        "method": "GET",
        "credentials": "include"
    });
    const bookJSON = await bookResp.json();
    console.log(bookJSON)

    for (const book of bookJSON['hydra:member']) {
        const author = await fetch(book.author, {
            "headers": {
                "accept": "application/ld+json",
                "authorization": "Bearer " + token,
            },
            "method": "GET",
            "referrer": "https://localhost/api",
            "referrerPolicy": "strict-origin-when-cross-origin",
            "method": "GET",
            "credentials": "include"
        });
        console.log(await author.json());
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant