Log Out a User's Magic Session

Log Out a User's Magic Session

Sometimes you will find yourself needing to log your users out from the server-side. This provides a small example of how to do so.

0. Prerequisite: Install Magic Admin SDK​

1. Invalidate the user session:

With public address

app.post('/logout', (req: any, res: any) => { const userPublicAddress = magicAdmin.token.getPublicAddress(req.headers.authorization); magicAdmin.users.logoutByPublicAddress(userPublicAddress); });

With DID Token

app.post('/logout', (req: any, res: any) => { magicAdmin.token.invalidate(req.headers.authorization); });
Log Out a User's Magic Session