Skip to content

generateJWT method does not respect function changes #160

Open
@danwbyrne

Description

@danwbyrne

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions