
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
- Login without email or phone number
I'm making a web app targeted towards users who are very tech illiterate, so a lot of them won't even have emails. I know that the only two "identifiers" for a...
- Password Recovery link takes upwards of ...
Hello. I am having this issue above. Is there a way to make this faster? I created this project a while back when appwrite only supported Frankfurt servers. Wil...
- React Native (Expo) Google OAuth not red...
Recently, I tested my app and found that the previous hack for the google auth is now not working anymore. After searching and reading docs, I was able to set i...
