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
- Error: User (role: guests) missing scope...
I want to send a verification code to the user and the given phone number and check it and create a session right after the user entered the secret. For me that...
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...