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

Issue with getSite and auth #194

Closed
tgxn opened this issue Oct 1, 2023 · 2 comments
Closed

Issue with getSite and auth #194

tgxn opened this issue Oct 1, 2023 · 2 comments

Comments

@tgxn
Copy link
Contributor

tgxn commented Oct 1, 2023

Previously, I was passing auth to getSite() in order to fetch the current user and their metadata.

It looks like the formData param has been removed:
ab7af88#r128832008

Is there an alternative way to pass auth in?

example code

const lemmyClient = new LemmyHttp(`https://${instanceBase}`);

const auth = await lemmyClient.login({
  username_or_email: username,
  password: password,
});

// as long aws there is a JWT in the response from login, logged in!
if (auth.jwt) {

  // this shows the `jwt` is present 👍
  console.log("auth", auth);

  // i tried this too, but didn't seem to work :/
  lemmyClient.setHeaders({
    Cookie:	`jwt=${auth.jwt}`
  });

  // this no longer has any params
  const getSite = await lemmyClient.getSite({
    auth: auth.jwt,
  });

  // but never any user data here :(
  console.log("getSite", getSite);
}   

Edit: forgot to mention, this was after upgrading to 0.19.0-rc.13 from 0.18.1

@tgxn
Copy link
Contributor Author

tgxn commented Oct 1, 2023

I've had a read of this LemmyNet/lemmy#3725 and the post about 0.19.x https://lemmy.world/post/5959696

It seems that we're meant to pass both the form data to ensure backwards-compatability

It should be possible for clients to support both Lemmy 0.18 and 0.19 without major workarounds. If backwards compatibility is causing you trouble, comment below and we will help to find a solution.

I suppose the issue is it means this library isn't backwards-compatible.

@dessalines
Copy link
Member

Correct, the library is not backwards compatible. Check out an older version if you need to use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants