Closed chiefGui closed 2 years ago
Weird enough, I tried two things:
await fetch('https://api.magic.link/v1/admin/auth/user/get?issuer=did%3Aethr%SOME_ID_HERE', { method: 'GET', headers: { 'X-Magic-Secret-Key': SECRET_KEY }})
Works ✅
const mAdmin = new Magic(SECRET_KEY, {
endpoint: 'https://api.magic.link',
})
Doesn't work 😢
.validate
is working properly.getMetadataByToken
as well.get
method is 🤔 https://github.com/magiclabs/magic-admin-js/blob/731a8cb440533b459eefc70d29d9f027e1db29fa/src/modules/users/index.ts#L31-L35Okay, I just dove deep and yes, it seems it's the SDK with the encodeURIComponent
function.
Because fetching the following doesn't work, contrary to the fetch
I posted above:
await fetch(`https://api.magic.link/v1/admin/auth/user/get?${encodeURIComponent('issuer=did:ethr:SOME_WEIRD_ID')}`, { method: 'GET', headers: { 'X-Magic-Secret-Key': 'SECRET_KEY' }})
(If I remove encodeURIComponent
it works like a charm.)
Thanks for you detailed report and investigation (and further initiative on a fix/PR). This is now released in @magic-sdk/admin@1.3.1
✅ Prerequisites
@magic-sdk/admin
)?🐛 Description
[Description of the bug.]
🧩 Steps to Reproduce
🤔 Expected behavior
Wanted to retrieve user's metadata.
😮 Actual behavior
Am consistently receiving 400 and no metadata.
💻 Code Sample
🌎 Environment
@magic-sdk/admin
yarn