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

generateJWT method does not respect function changes #160

Open
danwbyrne opened this issue Sep 23, 2022 · 2 comments
Open

generateJWT method does not respect function changes #160

danwbyrne opened this issue Sep 23, 2022 · 2 comments

Comments

@danwbyrne
Copy link

danwbyrne commented Sep 23, 2022

Description

The endpoint we use for fetching a JWT for iterable is itself behind a jwt authorizer - when this user token expires it is unknown how to pass this change to the generateJWT function already initialized in iterable.

Code example:

import { initialize } from '@iterable/iterable-web-sdk'

const IterableProvider = () => {
    const enabled = useFeatureFlag('iterable')
    const { userToken } = useUserToken();
    
    const handler = useCallback(async (request) => fetchJWT(userToken, request), [userToken])
    
    const iterableFunctions = useMemo(() => {
        if (enabled) {
            initialize(apiKey, handler)
        }
    }, [enabled])
}

in this scenario when the userToken expires and a new iterable JWT needs to be requested the jwt request will fail because it continues to use the expired token. Other workarounds I've tried are using a ref for the function, calling initialize again when the update happens, but none of these will update the generateJWT method.

Possible solution would just be giving us access to some kind of setGenerateJWT functionality.

@mprew97
Copy link
Contributor

mprew97 commented Feb 15, 2023

Apologies for the delay on this one. Will discuss with the team and get back to you. Have you been able to find any workarounds in the meantime?

@danwbyrne
Copy link
Author

@mprew97 our solution is to not use jwt api keys

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