Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

What could be a reason to get a 403 Forbidden when calling api/signin?code=<code>&state=<state>? I do get a valid access code when I call access api/login/oauth/access_token. Also, why do I need to call signin? (by the way, I'm on a SPA)

2views
2users
1 minread

api/signin?code=&state= is for your application to handle, not for casdoor

Correct. My application calls this at the application callback URL, yet it gives me back a 403 Forbidden. Oddly, even if I don't call api/signin. I can still request an access_token.

I mean api/signin?code=&state= is a HTTP handler in your own app, not Casdoor

Casdoor doesn't have any API with /api/signin

Of course you can change it because it's your app. change to /api/balabala

Found that strange too, also didn't see it in Swagger; but this is straight from the Casdoor sdk.js:

        const params = new URLSearchParams(window.location.search);
        const code = params.get("code");
        const state = params.get("state");
        const expectedState = this.getOrSaveState();
        this.clearState();
        if (state !== expectedState) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve({
                        // @ts-ignore
                        status: "error",
                        msg: `invalid state parameter, expected: ${expectedState}, got: ${state}`,
                    });
                }, 10);
            });
        }
        return fetch(`${serverUrl}${signinPath  this.config.signinPath  '/api/signin'}?code=${code}&state=${state}`, {
            method: "POST",
            credentials: "include",
        }).then(res => res.json());
    }

I now think that the '/api/signin' here might be an artifact of an older version of Casdoor?

1 / 6
Mar 2024