Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to use the getMetadataByToken method in Next JS 13 in api routes with an error Magic Admin SDK Error: [SERVICE_ERROR] #110

Open
2 tasks
hamedtarkashvand opened this issue Jun 8, 2023 · 0 comments

Comments

@hamedtarkashvand
Copy link

hamedtarkashvand commented Jun 8, 2023

✅ Prerequisites

  • Did you perform a cursory search of open issues? Is this question already asked elsewhere?
  • Are you reporting to the correct repository (@magic-sdk/admin)?

❓ Question

I want to use the getMetadataByToken method in Next JS 13 in api routes with an error Magic Admin SDK Error: [SERVICE_ERROR] A service error occurred while communicating with the Magic API. I observe

// config magic-admin.js

import { Magic } from "@magic-sdk/admin";
export const magicAdmin = new Magic(process.env.MAGIC_SECRET_KEY);
// pages/api/login.js

import { magicAdmin } from "@/lib/magic-admin";

export default async function login(req, res) {
  const auth = req.headers.authorization;
 const didToken = magicAdmin.utils.parseAuthorizationHeader(auth);
  if (req.method === 'POST') {
    try {
      const metaData = await magicAdmin.users.getMetadataByToken(didToken);
      console.log(metaData);
      res.send({ done: true });
    } catch (err) {
      console.error('something want error ===>', err);
      res.status(500).json({ done: false });
    }
  } else {
    res.send({ done: false });
  }

🌎 Environment

Software Version(s)
@magic-sdk/admin ^1.10.0
Node v18.15.0
Operating System windows 10
@hamedtarkashvand hamedtarkashvand changed the title [WHAT'S YOUR QUESTION?] I want to use the getMetadataByToken method in Next JS 13 in api routes with an error Magic Admin SDK Error: [SERVICE_ERROR] Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant