I can log in successful via LinkedIn OAuth and redirected back the successful url, and the user appears in Appwrite Cloud Auth section but getSession("current") throws a 401
Steps to reproduce...
- click login
- redirected to LinkedIn and login
- redirected to successul url on my app
- use
getSession("current")throws a401
TypeScript
const getAppwriteUser = async () => {
let session = {};
try {
session = await account.getSession("current");
let linkedinUser = {};
if (session) {
// fake data, get real profile info from LinkedIn
linkedinUser = {
imageUrl: "https://github.com/eddiejaoude.png",
name: "TEST",
email: "email TEST",
};
}
setUser(linkedinUser);
} catch (e) {
console.log(e);
setUser(null);
}
};
useEffect(() => {
getAppwriteUser();
}, []);
Console error
TypeScript
Failed to load resource: the server responded with a status of 401 ()
TL;DR
Title: LinkedIn OAuth successful login, but `getSession("current")` returns 401
In this support thread, a developer successfully logs in with LinkedIn OAuth and is redirected back to their application. The user's LinkedIn profile is also created in Appwrite Cloud.
However, when attempting to retrieve the current session using `getSession("current")`, the developer encounters a 401 error.
To resolve this issue, the developer should check if the OAuth2 session for LinkedIn was created properly and verify that the session token is being sent correctly to the backend. Additionally, it's important to ensure that the backend is properly configured to handle the LinkedIn OAuth flowWhat does your code for authenticating look like?
TypeScript
const login = async () => {
account.createOAuth2Session(
"linkedin",
`${process.env.NEXT_PUBLIC_BASE_URL}/success`,
`${process.env.NEXT_PUBLIC_BASE_URL}/failure`
);
};
I am able to log in on LinkedIn and redirected back to /success and my user was created in Appwrite Cloud
Recommended threads
- Why does this happen?
`AppwriteException: general_argument_invalid, Invalid `secret` param: Value must be a valid string and at least 1 chars and no longer than 256 chars (400)` the...
- How to properly implement custom domain?...
- Site deployment does not work.
I can change a file, deploy, change does not take effect. Delete file in repo, push changes,deploy. Old file remains undeleted Duplicate file, rename it, push,...