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

getUser returns a null value #1440

Open
China-jinannan opened this issue Mar 15, 2024 · 2 comments
Open

getUser returns a null value #1440

China-jinannan opened this issue Mar 15, 2024 · 2 comments
Labels
question Further information is requested

Comments

@China-jinannan
Copy link

import { UserManager, UserManagerSettings, WebStorageStateStore } from "oidc-client-ts";
import { appConfig } from "./appConfig";
const ums: UserManagerSettings = {
userStore: new WebStorageStateStore({ store: window.localStorage }),
authority: appConfig.eamConfig?.authority!,
redirect_uri: appConfig.eamConfig?.successRedirectUri || '',
post_logout_redirect_uri: appConfig.eamConfig?.logoutUri,
client_id: appConfig.eamConfig?.clientId || '',
response_type: "code",
scope: appConfig.eamConfig?.scope,
automaticSilentRenew: true,
silent_redirect_uri: "http://localhost:3000/signin-redirect-success",
};
export const userManager = new UserManager(ums);

const user = await userManager.getUser();
user is null

@China-jinannan
Copy link
Author

Unable to return email, FamilyName, GivenName

@pamapa pamapa added the question Further information is requested label Mar 15, 2024
@pamapa
Copy link
Member

pamapa commented Mar 15, 2024

Are you starting the signin? You need to call e.g. userManager.signinRedirect first. Then you must handle the callback, ...
See https://github.com/authts/oidc-client-ts/blob/main/docs/protocols/authorization-code-grant-with-pkce.md

Enabling logging also help you, see https://authts.github.io/oidc-client-ts/#md:logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants