-
I must be having a brain fade here. I was having trouble incorporating SKA into my existing app, so I dumbed it down to the vanilla SK template:
Getting the error:
What am I missing here? appAuth.jsimport { SvelteKitAuth } from "sk-auth";
import {
GoogleOAuth2Provider,
} from "sk-auth/providers";
const VITE_GOOGLE_OAUTH_CLIENT_ID = ''
const VITE_GOOGLE_OAUTH_CLIENT_SECRET = ''
const JWT_SECRET_KEY = 'secretkey'
export const appAuth = new SvelteKitAuth({
providers: [
new GoogleOAuth2Provider({
clientId: VITE_GOOGLE_OAUTH_CLIENT_ID,
clientSecret: VITE_GOOGLE_OAUTH_CLIENT_SECRET,
profile (profile) {
return { ...profile, provider: "google" };
},
})
],
callbacks: {
jwt (token, profile) {
if (profile?.provider) {
const { provider, ...account } = profile;
token = {
...token,
user: {
...(token.user ?? {}),
connections: { ...(token.user?.connections ?? {}), [provider]: account },
},
};
}
return token;
},
},
jwtSecret: JWT_SECRET_KEY,
}); /routes/login.svelte<script>
import { goto } from '$app/navigation';
async function DoLogin() {
goto('/api/auth/signin/google');
}
</script>
<h1>Login Page</h1>
<a href="/api/auth/signin/google">Click here to sign in</a>
<button on:click={DoLogin}>Initialize</button> |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
@SGarno are u sure that u have "src\routes\api\auth[...auth].ts" file ?
|
Beta Was this translation helpful? Give feedback.
-
Yup! I had it as .js but that shouldn't matter. I did change it to .ts just to be sure and then updated the jsconfig.json to include it. Still same issue. |
Beta Was this translation helpful? Give feedback.
-
DOH! I totally missed the |
Beta Was this translation helpful? Give feedback.
-
I'll be honest I stared at this thread way too long trying to figure out what was happening and yup! Lo and behold, sometimes you could show the thread to someone that hasn't touched code in their life with a higher chance of solving the issue. 😆 Glad you got it figured out! |
Beta Was this translation helpful? Give feedback.
DOH! I totally missed the
api
part of the path. Ok....I need to get away for a bit. My bad. I copied it from my project and didn't check when recreating the vanilla SK project.