Tokens are required to authenticate users. Sometimes, you wouldn’t want to keep authenticating users during development. In such cases, you can disable the token authentication and use client-side generated tokens.
Note - This is advised only for development and is unsuitable for production.
await client.connectUser(
{
id: ‘John’,
name: ‘John Doe’,
image: ‘https://getstream.io/random_svg/?name=John’,
},
client.devToken(‘John’),
);
You might end up seeing this error.
UnhandledPromiseRejectionWarning: Error: {"code":5,"StatusCode":401,"message":"WS failed with code 5 and reason - Connect failed with error: \"development tokens are not allowed for this application\"","isWSFailure":false}
This is because we need to disable authorization checks from the dashboard.
Disable Auth Checks
To enable development tokens, you need to disable Auth Checks for the application. This can be achieved either through the dashboard or through the API.
Dashboard
Go to App -> Chat -> Chat Overview -> Authentication -> Disable Auth Checks
Enable this option so creating development tokens is possible.
Update App Settings through the API
You can also disable/enable Auth Checks programmatically through the API.
// disable auth checks, allows dev token usage
await client.updateAppSettings({
disable_auth_checks: true,
});
// re-enable auth checks
await client.updateAppSettings({
disable_auth_checks: false,
});
Comments
0 comments
Please sign in to leave a comment.