
Hi, I am trying to get the user uid
from github on the server side in Nuxt. After login the session response it has the providerUid as empty string
. I also tried with get the current session or current user is the same result.
I am using appwrite 1.5.3 selfhosted
with nuxt
and node-appwrites@latest
my code:
login
TypeScript
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig(event);
const { account } = useAppwriteAdminClient(event);
try {
const redirectUrl = await account.createOAuth2Token(
'github',
`${config.public.api.url}/oauth`,
`${config.public.api.url}/login`,
['read:user', 'user:email']
);
return redirectUrl;
} catch (error) {
console.log('OAUTH ERROR', error);
}
});
TypeScript
export default defineEventHandler(async (event) => {
const { userId, secret } = getQuery<{ userId: string; secret: string }>(
event
);
if (!userId || !secret) {
return await sendRedirect(event, '/login');
}
const config = useRuntimeConfig(event);
const { account } = useAppwriteAdminClient(event);
try {
const session = await account.createSession(userId, secret);
console.log('SESSION', session);
const cookieName = APPWRITE_COOKIE_NAME;
setCookie(event, cookieName, session.secret, {
domain: config.public.app.url,
expires: new Date(session.expire),
path: '/',
httpOnly: true,
secure: true,
sameSite: 'strict'
});
return await sendRedirect(event, '/dashboard');
} catch (error) {
console.log(error);
}
});
logs in the screenshot
thank you
TL;DR
Issue: `providerUid` in the session response is an empty string when trying to get the user `uid` from GitHub in a Nuxt app using node-appwrite.
Solution:
- Check the appwrite version compatibility with the current setup.
- Ensure proper configuration for OAuth2 token creation with GitHub.
- Verify the correct usage of `createSession` method to fetch the user session details.
- Review the session data and handling to ensure providerUid is populated correctly.
Remember to validate the setup, configurations, and usage for proper retrieval of `providerUid` in the session response.Recommended threads
- Images not showing up --
so i made this movie app - i hosted it successfully using appwrite but the images arent showing up --- https://movie-app-jsm.appwrite.network/ this is the movie...
- What’s the current approach for always o...
Read that it’s not a thing out of the box, but what’s the possible setup here?
- Error 431 header fields too large
Some times to times when i load or switch the page, it shows an error 431. And on what i saw it'w because of the cookies, when i remove the legacy tokens it wo...
