Closed arus307 closed 1 year ago
Hi @arus307 , thank you very much for your issue. I am not sure if it is possible with the actual code : https://github.com/AxaGuilDEv/react-oidc/blob/e814384b2a8d84c895205db5d965d2b61936ec5f/packages/react/src/oidc/core/default-component/Callback.component.tsx#L21 I have to think for a very simple solution. Do you have an idea?
Hi @arus307 ,
It is possible to add a callback like the onsession lost. onSessionLost={onSessionLost}
But it will require to call the vanilla api getOidc(configurationName).loginCallbackAsync(); From somewhere on your own. For example: onCallback={onCallback}
Thanks for your comment @guillaume-chervet
getOidc(configurationName).loginCallbackAsync();
I used this in CallbackSuccess
component and I got accessToken.
Thank you for your answer!
Hi @arus307 , i think i should add a callback method like the onSession lost. If your are using the reactcomponentcallback override, it can bug because callback method is called 2 times.
Thank you @guillaume-chervet .
I may not have understood it well enough.
I am using the flag with useRef in CallbackSuccess to suppress the two calls.
so it look like it is only called once.
But is it still a possible bug?
If I add a callback method like the session lost, could it be written smarter?
@arus307 , i am curious now. I do not have any idea about how you did it. Do you have a sample of code?
@guillaume-chervet I'm sorry, it seems I misread.
I wrote code to prevent it from being called twice inside the CallbackSuccessComponent.
like this
const CallbackSuccess = () => {
// some code
if(isFirstTimeInThisComponent){
//called only once "in this component"
getOidc(configurationName).loginCallbackAsync()
}
return null;
};
If your are using the reactcomponentcallback override, it can bug because callback method is called 2 times.
Did this means getOidc(configurationName).loginCallbackAsync()
will be called twice with the following timing?
1.In library react-oidc/packages/react/src/oidc/core/default-component/Callback.component.tsx
Issue and Steps to Reproduce
I'm trying the demo project and wanted to set the callbackSuccessComponent and get the access token, but I can't.
App.tsx
CallbackSuccess.tsx
Expected
Actual
Additional Details
After logging in and before transitioning to a page, after getting an access token, I want to send a request with the token to a backend API I'm developing to get additional information about the user like user name in my service.