Skip to content

Commit

Permalink
fix(livestream-app): use a correct token type (#907)
Browse files Browse the repository at this point in the history
Ignore the token provided by the documentation tutorials. Live streaming
examples should use anonymous user tokens.
  • Loading branch information
oliverlaz authored Aug 7, 2023
1 parent e3a4636 commit 0988039
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sample-apps/react/livestream-app/src/hooks/useInitVideoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export const useInitVideoClient = ({
}: PropsWithChildren<VideoClientProviderProps>) => {
const { callId } = useParams<{ callId: string }>();
const { api_key, token, type } = getURLCredentials();
const user = useMemo(getUser, []);
const user = useMemo(() => {
if (isAnon) {
return { id: '!anon' };
}
return getUser();
}, [isAnon]);
const apiKey = api_key ?? envApiKey;

const [client, setClient] = useState<StreamVideoClient>();
Expand All @@ -41,8 +46,8 @@ export const useInitVideoClient = ({
};
const _client = new StreamVideoClient({
apiKey,
tokenProvider,
token,
...(isAnon && { tokenProvider }),
...(!isAnon && { token }),
user: isAnon ? { type: 'anonymous' } : role ? { ...user, role } : user,
});
setClient(_client);
Expand Down

0 comments on commit 0988039

Please sign in to comment.