Graphql throwing error invalid session

I’m using realm-graphql in my electron app. Now I’m facing an error while I’m passing authentication token in the header of graphql request.
This is the error:

Error: Network error: invalid session: failed to find refresh token
at new ApolloError.

Here’s my code:

    async function getValidAccessToken () {
     const app = await getRealmApp()
    // Guarantee that there's a logged in user with a valid access token
    if (!app.currentUser) {
    // If no user is logged in, log in an anonymous user. The logged in user will have a valid
    // access token.
    const token = 'xyz....'
    if (token) {
      const credentials = Realm.Credentials.jwt(token);
      await app.logIn(credentials);
    } 
  } else {
    // An already logged in user's access token might be stale. To guarantee that the token is
    // valid, we refresh the user's custom data which also refreshes their access token.
    await app.currentUser.refreshCustomData()
  }
  return app.currentUser.accessToken
}