#Type error in Next Auth provider

15 messages · Page 1 of 1 (latest)

gusty jacinth
#

Hi guys,
i was trying to build my project but i get this error:

fallen idolBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

gusty jacinth
#

thats my types file

agile berry
#

Your environment variables could be undefined, so TypeScript is complaining.
Change:

  • process.env.DISCORD_ CLIENT_ID to process.env.DISCORD_ CLIENT_ID as string
  • process.env.DISCORD_CLIENT_SECRET to process.env.DISCORD_CLIENT_SECRET as string

Also check out: https://env.t3.gg/docs/nextjs

Env

Never build your apps with invalid environment variables again. Validate and transform your environment with the full power of Zod.

gusty jacinth
#

thanks

gusty jacinth
#

Argument of type '{ clientId: string; clientSecret: string; callbackUrl: string | undefined; token: string; userinfo: string; authorization: { params: { scope: string; }; }; }' is not assignable to parameter of type 'OAuthUserConfig<any>'.
Object literal may only specify known properties, and 'callbackUrl' does not exist in type 'OAuthUserConfig<any>'.ts(2345)

glacial prawn
#

you can also just add ! to the end

process.env.DISCORD_CLIENT_ID!
process.env.DISCORD_CLIENT_SECRET! process.env.DISCORD_CLIENT_SECRET!
glacial prawn
gusty jacinth
# glacial prawn but do the same thing that you did for the other 2 for this one

i've tried but i still get the same error:
Type error: Argument of type '{ clientId: string; clientSecret: string; callbackUrl: string; token: string; userinfo: string; authorization: { params: { scope: string; }; }; }' is not assignable to parameter of type 'OAuthUserConfig<any>'.
Object literal may only specify known properties, and 'callbackUrl' does not exist in type 'OAuthUserConfig<any>'.

glacial prawn
#

ahh callbackurl isn't an option...

gusty jacinth
#

oh lol, sorry

glacial prawn
#

yeah because the callback is done automatically by nextauth

#

and have you added the callback of the folowing to your discord redirects section for the app:
http://localhost:3000/api/auth/callback/discord (and change the domain for your actual domains too)

fallen idolBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer