[SOLVED] Moralis not linking account to an existing user

I have a problem in linking authenticated user’s others account as explained in moralis docs. My current implementation is inside useEffect hook of layout file in nextjs app
useEffect(() => {
Moralis.onAccountChanged(async accountSelected => {
const isLinked = user?.attributes.accounts.find((acct: any) => acct === accountSelected)

  if (!isLinked) {
    const confirmed = confirm("Link this address to your account?")
    if (confirmed) {
      try {
        await Moralis.link(accountSelected as string)
      } catch (e) {

}, [])

And the error I get inside console is

Error: Insufficient auth.
at handleError (RESTController.js:438:1)

I am not sure what this insufficient auth means. User is already logged in with other account.

you will need latest version of Moralis SDK to fix that error

Thanks, that worked like a magic.

1 Like