
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
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);
}
});
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
Recommended threads
- SSO google apple not working anymore
We use Apple and Google sso in our react native app. Everything worked fine until we noticed today that we see general argument error. We did not change anythi...
- Origin error after changing default port...
Hi! I need some help regarding an issue I’m facing with Appwrite after changing the default ports. I have a self-hosted Appwrite instance running on my VPS. I ...
- Opened my website after long time and Ba...
I built a website around a year back and and used appwrite for making the backend. At that time the website was working fine but now when i open it the images a...
