Git Product home page Git Product logo

Comments (8)

alanpoulain avatar alanpoulain commented on July 29, 2024

Hello, have you followed https://api-platform.com/docs/admin/authentication-support/?

from api-doc-parser.

RSalo avatar RSalo commented on July 29, 2024

@alanpoulain Hello. Yes, I did all according to this documentation.

from api-doc-parser.

alanpoulain avatar alanpoulain commented on July 29, 2024

It doesn't seem so. For instance:

    const customFetchHydra = (url, options = {}) => {
        fetchHydra(url, {
            ...options,
            headers: new Headers(getHeaders()),
        })
    };

Should be:

    const customFetchHydra = (url, options = {}) => {
        fetchHydra(url, {
            ...options,
            headers: getHeaders,
        })
    };

from api-doc-parser.

RSalo avatar RSalo commented on July 29, 2024

@alanpoulain i did it too. Was trying different variants and nothing change...

from api-doc-parser.

alanpoulain avatar alanpoulain commented on July 29, 2024

You need to change the apiDocumentationParser too:

const apiDocumentationParser = async (entrypoint) => {
    const { api } = await parseHydraDocumentation(entrypoint, { headers: getHeaders });
    return { api };
};

from api-doc-parser.

RSalo avatar RSalo commented on July 29, 2024

@alanpoulain added as third parameter

    const apiDocumentationParser = async (entrypoint) => {
        try {
            const { api } = await parseHydraDocumentation(entrypoint, { headers: getHeaders });
            return { api };
        } catch (result) {
            if (result.status === 401) {
                // Prevent infinite loop if the token is expired
                localStorage.removeItem("token");

                return {
                    api: result.api,
                    customRoutes: [
                        <Route path="/" />
                    ],
                };
            }

            throw result;
        }
    };
    const dataProvider = hydraDataProvider(API_ENTRYPOINT, customFetchHydra, apiDocumentationParser);

And the same situation. I have no idea, it's my fail or bug...

from api-doc-parser.

RSalo avatar RSalo commented on July 29, 2024

Find out that we have no header options at all:
https://github.com/api-platform/admin/blob/main/src/hydra/dataProvider.js#L245
So "options.headers" is empty and we creating an empty header object
https://github.com/api-platform/admin/blob/main/src/hydra/fetchHydra.js#L20
As we have clear headers our parser makes a request without any headers
https://github.com/api-platform/admin/blob/main/src/hydra/fetchHydra.js#L28

I can be mistaken...

from api-doc-parser.

alanpoulain avatar alanpoulain commented on July 29, 2024

Closing because it was not followed. It seems other users don't have similar issues. Please reopen if it's the case.

from api-doc-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.