description |
---|
Gets the cryptographic public address of the Magic User who generated the supplied token. |
getPublicAddress(didToken)
didToken
(String): A Decentralized ID Token generated by a Magic user on the client-side.
string
: The public address of the Magic User who generated the DID Token.
const { Magic } = require('@magic-sdk/admin');
const mAdmin = new Magic('SECRET_API_KEY');
...
/* Gets the DID token from a login request */
app.get('/login', async (req: any, res: any) => {
/*
Assumes DIDToken was passed in the Authorization header
in the standard `Bearer {token}` format.
*/
const DIDToken = req.headers.authorization.substring(7);
const publicAddress = mAdmin.token.getPublicAddress(DIDToken);
/* You can use this as the ID column in your own tables */
});