Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Latest commit

 

History

History
39 lines (27 loc) · 1 KB

getpublicaddress.md

File metadata and controls

39 lines (27 loc) · 1 KB
description
Gets the cryptographic public address of the Magic User who generated the supplied token.

getPublicAddress

Arguments

getPublicAddress(didToken)

Returns

string: The public address of the Magic User who generated the DID Token.

Example

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 */
});