-
Notifications
You must be signed in to change notification settings - Fork 247
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
Error using D1+Auth.js in CF Starter - [auth][details] TypeError: immutable #38
Comments
Got this working with your exact auth.ts setup, error was resolved by making sure the dropbox app included the exact scope fields being included in the scope params being inserted into the authorise url. Let me know how you go and I'll try to help :) |
same issue with immutable error. in my case, the d1 database schema on local was not migrated |
@curtis-allan Thanks for trying and offering to help 🙏
@inurhuda00 I checked using TablePlus and could confirm that the migrations where there. Running the migration again would also give me an error:
I just tried this from scratch and still seeing the immutable error. Below are the specific steps I took:
diff --git a/apps/web/app/server/auth.ts b/apps/web/app/server/auth.ts
index ba64138..01e7b76 100644
--- a/apps/web/app/server/auth.ts
+++ b/apps/web/app/server/auth.ts
@@ -1,6 +1,5 @@
import { DrizzleAdapter } from '@auth/drizzle-adapter';
import NextAuth from 'next-auth';
-import Google from 'next-auth/providers/google';
import { db } from './db';
export const {
@@ -21,9 +20,33 @@ export const {
},
adapter: DrizzleAdapter(db),
providers: [
- Google({
- clientId: process.env.GOOGLE_CLIENT_ID,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
- }),
+ {
+ id: 'dropbox',
+ name: 'Dropbox',
+ type: 'oidc',
+ clientId: process.env.AUTH_DROPBOX_ID,
+ clientSecret: process.env.AUTH_DROPBOX_SECRET,
+ allowDangerousEmailAccountLinking: true,
+ issuer: 'https://www.dropbox.com',
+ wellKnown: 'https://www.dropbox.com/.well-known/openid-configuration',
+ authorization: {
+ url: 'https://www.dropbox.com/oauth2/authorize',
+ params: {
+ scope: 'openid email account_info.read files.content.read', //files.metadata.read
+ token_access_type: 'offline',
+ response_type: 'code', // OICD
+ },
+ },
+ // Dropbox always provides a verified email: https://developers.dropbox.com/oidc-guide
+ token: {
+ url: 'https://api.dropboxapi.com/oauth2/token',
+ },
+ profile(profile) {
+ return {
+ ...profile,
+ name: profile.given_name,
+ };
+ },
+ },
],
}); diff --git a/apps/web/app/page.tsx b/apps/web/app/page.tsx
index 72bfc61..0089b01 100644
--- a/apps/web/app/page.tsx
+++ b/apps/web/app/page.tsx
@@ -106,7 +106,7 @@ export default async function Page() {
<form
action={async () => {
'use server';
- await signIn('google');
+ await signIn('dropbox');
}}
>
<Button className="mt-4">Login with Google</Button> Confirmed I've all the scopes I'm requesting are provided allowed in the dropbox app too:Error:Versions
|
Make sure the profile scope is checked as well in the dopbox app, its needed for your auth setup. Let me know if that does anything. |
Tried that too. Checked profile in Dropbox App Settings and added
Dropbox redirects to |
Hi! Please refer to this issue: |
This worked for others - #15 (comment) |
Something strange happened where the auth with dropbox worked the first time, and then stopped working.
Changes
Below are the only changes made after bootstrapping using
bun setup
Trace
Related conversation:
nextauthjs/next-auth#9966
The text was updated successfully, but these errors were encountered: