progressive-amaranthP
Refine2y ago
3 replies
progressive-amaranth

useCustomMutation authorization issue

Hello,

I am using GraphQL, and I want to send a mutation to verify the two-factor authentication of a user then logs him in, everything is good with the backend, it works well when testing with postman, but when trying to implement it in my refine app I get "Unauthorized" error despite passing the Authorization bearer token in the headers, here is what I do:
loginTwoFactorAuthentication({
      url: API_URL,
      method: "post",
      config: {
        headers: {
          // Send the short-lived token in the Authorization header
          Authorization: `Bearer ${shortLivedToken}`,
        },
      },
      meta: {
        gqlMutation: MUTATION_LOGIN_TWO_FACTOR_AUTHENTICATION,
        variables: {
          loginTwoFactorAuthenticationInput: {
            userId: "toVerify",
            otp: code,
          },
        },
      },
      values: {},
    });

When sending this mutation, onError is called with "Unauthorized" error, what am i doing wrong ?
Was this page helpful?