0

Good evening, Im developing a web app in react where i wanted to use oidc-client-js to make authentication. However,when i run this code below:

const userManager = new UserManager({
    authority: "https://accounts.google.com/.well-known/openid-configuration",
    client_id: "*myclientid*",
    redirect_uri: "http://localhost:3000/projects",
});

const loginUser = (_) => {
    userManager
        .signinRedirectCallback()
        .then((user) => {
            alert(user);
        })
        .catch((error) => {
            alert(error);
        });
};

I get the Error: No state in response.

After some searching on this error i already tried to put the response_mode:'query' on the UserManager object but it didnt work out.

Thanks in advance.

Serg
  • 2,346
  • 3
  • 29
  • 38

1 Answers1

1

I assume that this code is to handle the response (tokens) received from idp right?

if so, did you check the signin request? as part of the request, client needs to send state (in url) and idp returns the same state back to client, so that client side, it validates that it is receiving the response for the request the client is initiated (like a hand shake)

where ever you are initiating the sign in request, pass in state and verify the state value (some random 15 digit uuid) is being passed along with authroize request.

userManager.signinRedirect({ state: { bar: 15 } });

hashbytes
  • 769
  • 1
  • 8
  • 26