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

Token multiple call #1393

Closed
YaoHure opened this issue Jun 28, 2024 · 10 comments
Closed

Token multiple call #1393

YaoHure opened this issue Jun 28, 2024 · 10 comments

Comments

@YaoHure
Copy link

YaoHure commented Jun 28, 2024

Issue and Steps to Reproduce

After logging into the application when I see in the log, there are a lot of calls to the token. Like about very 30sec or less ...

Versions

"@axa-fr/react-oidc": "^7.22.8",

Screenshots

image

Config

client_id: 'my_clientid', redirect_uri: window.location.origin + '/oidc-callback', silent_redirect_uri: window.location.origin + '/silent-oidc-callback', scope: 'profile offline_access openid profile_extended + my_scopes', authority: GetConfig('ssoUrl'), service_worker_relative_url: '/OidcServiceWorker.js', service_worker_only: true, demonstrating_proof_of_possession: false, acr_values: 'externalAmrAzureEnable:1', loadUserInfo: true, extras: { acr_values: 'externalAmrAzureEnable:1', },

  • Installed packages:
    Using react.js and vite
@guillaume-chervet
Copy link
Contributor

hi @YaoHure ,

Did you tried to set token_renew_mode: TokenRenewMode.access_token_invalid,
in your configuration?

Do you have a sample of your tokens ?

@YaoHure
Copy link
Author

YaoHure commented Jul 1, 2024

Hi @guillaume-chervet,

When i try to put the token_renew_mode: TokenRenewMode.access_token_invalid it worse the token is call almost every 5 secs.

Here is an sample of tokens and scope that i send :

{
    "id_token": "abcdJhbGciOiJSUzI1NiIsImtpZCI6IkNEMTIzNEE2NzZBMTlGN0U5MzQ5MkQ0QzQ2Q0IyNkZEIiwidHlwIjoiSldUIn0.eyJuYmYiOjE3MjAxMDE2NTYsImV4cCI6MTcyMDgcyMDEwMTU1OSwiaWRwIjoiQXp1cmVBRCIsImFtcjI6WyJleHRlcmAvQ3EXJtDlTGmXrAPrC3kRlyFZ8fYuBtAwFc2qFY4s_gyAHTDkBPI1bsDT5n9VtTch8HI8f6aWMRSCuWQ5C3aU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iSldUIn0.eyJuYmYiOjE3MjAxMDE2NTYsImV4cCI6MTcyMXvLZgVFk1FJduOBgBd6gThFYDQdXOsG3W2MOTY2v1Yb4In9gWFBtO0kALdBPQy5I8f6aWMRSCuWQ5C3aUzY3vbLKoa34XQ0HQLQxrdI1l5BYdxgMNb5zxz5-ovxZb5WInP9hqKDSr8_LIjPRYflmJ8U1ddqGxnAlDWRXzA7vQQtVHJZGoZVpFGFBB5Sxi6d6WhR7lhOsniKtRC84nTxZs0gRyO-HyYVqUqtfLcyo2uOzxQ9wZSI6WyJvcGVuaWQiLCJwcm9maWxlIiwicHJvZmlsZV9leHRlbmRlZCIsInBob2VuaXguc2VhcmNoLnJlYWQiLCJkb21haW4uY29tcGFuaWVzLnJlYWQiLCJkb21haW4udGlja2V0aW5nLnJlYWQiLCJkb21haW4udGlja2V0aW5nLndyaXRlIiwiYXBpX2F1dGhvcml6YXRpb25fYWNjZXNzIiwiZG9tYWlUu7avnR9TH7C-lhbu_UBv86_bOxWZzm3s7r0lRIshAl4F-qU2whcfegmNxvEqiv91XLDaCsDMr9XAYuaUgHY1Y4vw593J0xfPfO4RhFgo9smSPySCe3YDpBphhe6Q4AwQkzqp8PiBpbmIwxXQE4OgaUBKAKQelahX0dq3AF_hiJ4uBBoRDi_8picnMqEVRFoNLZMNMXuMQK0a8FS-MA_5oLkktWudpokd7sODsL5_IyHWILFteFLQpc4cR61qSlHI08aW95tQDtx7DLnNQ",
    "expires_in": 120,
    "token_type": "Bearer",
    "refresh_token": "885552A4C3A2D9AA20E008F7001C259844Y6ED00EFA1FBB5845EDFRE80",
    "scope": "openid profile profile_extended offline_access"
}

@guillaume-chervet
Copy link
Contributor

Do you know the lifetime of your access_token and refresh_token ? @YaoHure

@guillaume-chervet
Copy link
Contributor

You can also set the default behavior to refresh only when needed https://github.com/AxaFrance/oidc-client/blob/main/examples%2Freact-oidc-demo%2Fsrc%2Fconfigurations.ts#L20

It require you to use fetch from the library to ensure a correct behavior.

@YaoHure
Copy link
Author

YaoHure commented Jul 1, 2024

@guillaume-chervet access_token : 120sec and refresh_token : 30 days

@YaoHure
Copy link
Author

YaoHure commented Jul 1, 2024

I use to put this : token_automatic_renew_mode: TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted,

but i don't why like 30min after I received any more tokens ...

or do i need to put a new config inside of the openId ?

@guillaume-chervet
Copy link
Contributor

hi @YaoHure ,
it will ask for a new token only when needed. It require to use for example

const { fetch } = useOidcFetch(window.fetch, props.configurationName);

or to use this method before an http call :

const getValidToken = await getValidTokenAsync(oidc);

@YaoHure
Copy link
Author

YaoHure commented Jul 3, 2024

Hi @guillaume-chervet
Can you please provide me a real example of implementation of :

const { fetch } = useOidcFetch(window.fetch, props.configurationName);

cause i don't understand what should i put instead of props.configurationName .

@guillaume-chervet
Copy link
Contributor

configurationName is not mandatory @YaoHure , default is "default". it is used when you have multiple authentication with multiple configuration.

@YaoHure
Copy link
Author

YaoHure commented Oct 29, 2024

I will close this issue i found the solution

@YaoHure YaoHure closed this as completed Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants