📖 User Authentication
Prompting the user to sign in using an OAuth
connection has
never been easier! Just use the signin
method to send the request
and the listen to the signin
event to handle the token result.
app.on('message', async ({ signin, send }) => {
const state = {}; // ... fetch some state
if (!state.authenticated) {
await send({
type: 'message',
text: 'please sign in so I can help you...',
});
await signin('connection-name');
return;
}
await send({
type: 'message',
text: 'you are already signed in!',
});
});
app.event('signin', async ({ tokenResponse }) => {
// do something with the token...
});