Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate the with-authjs example #1304

Merged
merged 10 commits into from
Mar 11, 2024
Merged

Conversation

birkskyum
Copy link
Member

The https://mediakit-taupe.vercel.app/auth/install appear to need a bit of attention in order to fix this, but I've fixed most of the in this branch

Copy link

changeset-bot bot commented Feb 3, 2024

⚠️ No Changeset found

Latest commit: 3995be5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@birkskyum
Copy link
Member Author

it's a quite popular solution, so it would be great to have working.
Screenshot 2024-02-03 at 13 40 48

the error i get is from the api route:

UnknownAction: Cannot parse action at /api/auth/session .Read more at https://errors.authjs.dev#unknownaction

@birkskyum birkskyum force-pushed the solidjs-authjs branch 3 times, most recently from 0c71c8f to aaad022 Compare February 9, 2024 00:52
@birkskyum birkskyum force-pushed the solidjs-authjs branch 2 times, most recently from 21e2781 to 4d7cc09 Compare February 29, 2024 21:17
@ryansolid
Copy link
Member

How's it going? Any blockers I should know about?

@birkskyum
Copy link
Member Author

birkskyum commented Mar 8, 2024

I am awaiting an update to the mediakit auth package as it was on an old version of the auth.js library - will try this again soon when this recent commit hits a release solidjs-community/mediakit@446e30f

@birkskyum
Copy link
Member Author

birkskyum commented Mar 11, 2024

@OrJDev , i keep hitting this error with server response with Discord, even when setting the appropriate env vars: "{"client_id": ["Value "undefined" is not snowflake."]}"

have you hit that before?

@OrJDev
Copy link
Contributor

OrJDev commented Mar 11, 2024

@OrJDev , i keep hitting this error with server response with Discord, even when setting the appropriate env vars: "{"client_id": ["Value "undefined" is not snowflake."]}"

have you hit that before?

Never. Im not the one who made this example, please use create jd app to create a fully working example with Solid Start & AuthJs.

pnpm create jd-app@latest

http://github.com/orjdev/create-jd-app

@birkskyum
Copy link
Member Author

birkskyum commented Mar 11, 2024

I tried that just now - it gives me a repo with very old deps (auth/core, @solidjs/start, vite etc.) and after setting the discord id/secret i see this:

Screenshot 2024-03-11 at 17 42 54

My current redirect url is:
http://localhost:3000/api/auth/discord/callback

@OrJDev
Copy link
Contributor

OrJDev commented Mar 11, 2024

I tried that just now - it gives me a repo with very old deps (auth/core, @solidjs/start, vite etc.) and after setting the discord id/secret i see this:

Screenshot 2024-03-11 at 17 42 54

My current redirect url is:

http://localhost:3000/api/auth/discord/callback

Wdym old deps? Also check out the redirect uri on the url on discord and send it here

@birkskyum
Copy link
Member Author

birkskyum commented Mar 11, 2024

I ran npm create jd-app@latest, ticked only the Auth, and got this which is quite old vinxi, solid-start, vite, auth/code etc.:

// package.json

  "devDependencies": {
    "@types/node": "^18.14.0",
    "@typescript-eslint/eslint-plugin": "^5.52.0",
    "@typescript-eslint/parser": "^5.52.0",
    "eslint": "^8.34.0",
    "eslint-plugin-solid": "^0.9.4",
    "typescript": "^4.9.5",
    "vite": "^4.4.9"
  },
  "dependencies": {
    "@solidjs/router": "^0.11.2",
    "@solidjs/start": "^0.5.2",
    "solid-js": "^1.8.14",
    "vinxi": "^0.2.1",
    "@solidjs/meta": "^0.29.3",
    "zod": "^3.22.4",
    "@auth/core": "0.15.0",
    "@solid-mediakit/auth": "^2.0.2"
  },

The url when i try to login is this:

https://discord.com/oauth2/authorize?scope=identify+email&response_type=code&client_id=1207977196929683456&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fcallback%2Fdiscord&code_challenge=ynY9Rq1HmWluX9R1HO-qi3zdrSjcDzLxxlOKkOrlwjs&code_challenge_method=S256

and inside my discord dev panel the redirect url is set to:
http://localhost:3000/api/auth/discord/callback

And None in the Default Authorization Link

@OrJDev
Copy link
Contributor

OrJDev commented Mar 11, 2024

redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fcallback%2Fdiscord

redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fcallback%2Fdiscord

It's trying to redirect to

http://localhost:3000/api/auth/callback/discord

So try and set it to this. Also deps could always be updated with one single command.

@birkskyum
Copy link
Member Author

Thanks, that did the trick! It was the callback/discord that i had swapped in the url

@birkskyum
Copy link
Member Author

birkskyum commented Mar 11, 2024

@ryansolid , this is now finally ready as a direct port of the old example.

@birkskyum birkskyum marked this pull request as ready for review March 11, 2024 17:23
@birkskyum birkskyum changed the title WIP - Migrate the with-authjs example Migrate the with-authjs example Mar 11, 2024
@ryansolid
Copy link
Member

Awesome thank you

@ryansolid
Copy link
Member

Yeah this looks way cleaner

@ryansolid
Copy link
Member

ryansolid commented Mar 11, 2024

Yeah I will merge this. Only thing I'm unclear is how this solution works with route load functions. To be fair the context provider will be available in them it is just less clear to me the patterns here.

In any case, thank you @birkskyum and @OrJDev for getting this together. This is a common question and this solution looks really clean.

@ryansolid ryansolid merged commit 8c68fbd into solidjs:main Mar 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants