Eddie Jaoude | EddieHubOriginal post
Rank 2: Process
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
JavaScript
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
Failed to load resource: the server responded with a status of 401 ()
Summary
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 flow