LIFE
LIFE
KKinde
Created by LIFE on 5/8/2024 in #💻┃support
Unable to retrieve claims & identity from token
No description
16 replies
KKinde
Created by LIFE on 3/23/2024 in #💻┃support
How to get organization name in React SDK
No description
4 replies
KKinde
Created by LIFE on 3/5/2024 in #💻┃support
error: getuser is not a function
I get the error:
Header.tsx:18 Uncaught (in promise) TypeError: getUser is not a function
at getUsr (Header.tsx:18:22)
at Header.tsx:22:3
at commitHookEffectListMount (chunk-ZRJG7NCB.js?v=c5ae9bae:16904:34)
at commitPassiveMountOnFiber (chunk-ZRJG7NCB.js?v=c5ae9bae:18152:19)
at commitPassiveMountEffects_complete (chunk-ZRJG7NCB.js?v=c5ae9bae:18125:17)
at commitPassiveMountEffects_begin (chunk-ZRJG7NCB.js?v=c5ae9bae:18115:15)
at commitPassiveMountEffects (chunk-ZRJG7NCB.js?v=c5ae9bae:18105:11)
at flushPassiveEffectsImpl (chunk-ZRJG7NCB.js?v=c5ae9bae:19486:11)
at flushPassiveEffects (chunk-ZRJG7NCB.js?v=c5ae9bae:19443:22)
at chunk-ZRJG7NCB.js?v=c5ae9bae:19324:17
Header.tsx:18 Uncaught (in promise) TypeError: getUser is not a function
at getUsr (Header.tsx:18:22)
at Header.tsx:22:3
at commitHookEffectListMount (chunk-ZRJG7NCB.js?v=c5ae9bae:16904:34)
at commitPassiveMountOnFiber (chunk-ZRJG7NCB.js?v=c5ae9bae:18152:19)
at commitPassiveMountEffects_complete (chunk-ZRJG7NCB.js?v=c5ae9bae:18125:17)
at commitPassiveMountEffects_begin (chunk-ZRJG7NCB.js?v=c5ae9bae:18115:15)
at commitPassiveMountEffects (chunk-ZRJG7NCB.js?v=c5ae9bae:18105:11)
at flushPassiveEffectsImpl (chunk-ZRJG7NCB.js?v=c5ae9bae:19486:11)
at flushPassiveEffects (chunk-ZRJG7NCB.js?v=c5ae9bae:19443:22)
at chunk-ZRJG7NCB.js?v=c5ae9bae:19324:17
i've tried two different approches:
const { getUser, isLoading } =
useKindeAuth();

useEffect(() => {
if (!isLoading) return;

const getUsr = async () => {
console.log("getting user");
const usr = await getUser();
return usr;
};

getUsr().then((user) => {
console.log("name", user.given_name);
console.log("name family", user.family_name);
});
}, [isLoading]);
const { getUser, isLoading } =
useKindeAuth();

useEffect(() => {
if (!isLoading) return;

const getUsr = async () => {
console.log("getting user");
const usr = await getUser();
return usr;
};

getUsr().then((user) => {
console.log("name", user.given_name);
console.log("name family", user.family_name);
});
}, [isLoading]);
const usr = await getUser();
console.log("name", usr.given_name);
const usr = await getUser();
console.log("name", usr.given_name);
I was unable to find a lot of documentation on this except for this https://kinde.com/docs/developer-tools/react-sdk/#api-references--usekindeauth-hook:~:text=.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c%3B-,getUser,-Link%20to%20this
20 replies
KKinde
Created by LIFE on 12/18/2023 in #💻┃support
Automatically set token in header
No description
5 replies
KKinde
Created by LIFE on 12/6/2023 in #💻┃support
Resolving auth in back-end (.NET) with token retrieved from front-end (React)
Hello, i have finished a setup in react, but i need to use the token to authenticate and authorize the user in the back-end. AFAIK there are no documents on Kinde elaborating on this issue, would anyone be able to support? In .NET authentication is added:
var jwtIssuer = builder.Configuration.GetSection("Jwt:Issuer").Get<string>();

builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

})
.AddJwtBearer(options =>
{
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidIssuer = jwtIssuer,
};
});
var jwtIssuer = builder.Configuration.GetSection("Jwt:Issuer").Get<string>();

builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

})
.AddJwtBearer(options =>
{
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidIssuer = jwtIssuer,
};
});
but the access_token is always null
[HttpGet]
public async Task<IActionResult> C()
{
var a = HttpContext.User;
var accessToken = await HttpContext.GetTokenAsync("access_token");
return Ok("test B");
}
[HttpGet]
public async Task<IActionResult> C()
{
var a = HttpContext.User;
var accessToken = await HttpContext.GetTokenAsync("access_token");
return Ok("test B");
}
49 replies