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
FirebaseAdapter and Firebase giving "import" error #5551
Comments
i am getting the same error. did you solve it? @bcthakre |
Not yet @mucahitkok . Have asked on stackoverflow as well. |
Looks like the latest release did not include the compiled version of the package https://github.com/nextauthjs/next-auth/releases/tag/%40next-auth%2Ffirebase-adapter%40v1.0.2 🤔 https://github.com/nextauthjs/next-auth/actions/runs/3214540412/jobs/5255017831#step:6:101 The build was initiated but the output was still wrong. reverting to |
Thanks @balazsorban44 . Novice here. Shall I just revert back the next-auth to version 1.0.1 |
I highly advise not to use the current firebase adapter - for details please check out this link. |
Thanks @NorbertHuethmayr and @balazsorban44 . Solved the issue (seems like) by downgrading version. @mucahitkok happy to share the solution |
Thanks @balazsorban44, downgrading to version 1.0.1 solved for me. |
@balazsorban44 Is there a specific guidance on how to change firestore security rules to add / view users with the adapter. |
having the same issue. patiently waiting for a fix, thank you ;) |
You better look at this PR - maybe you can even upvote so that we get a bit more love from the maintainers. |
downgrading doesn't work for me 🥲 |
@alpharaoh , what works for me right now is this: insall @next-auth/firebase-adapter@experinental, |
Downgrading did not work on my end. Looking forward to a fix 🙃 |
Temporarily for this new version of firebase-adapter In the project, use the next-transpile-modules lib In version 13 of next we can use it inside next.config.js
|
In the meantime I've had some luck by doing the following:
Here's what that code looks like:
Then in my app I can call |
Thanks @hsdonkin . Can you please share the nextauth piece where you have used firestore adapter to connect to firebase for storing users. And what version of adapter you have used. |
This is my replacement for the adapter entirely, the |
Let me give it a try this weekend. |
I would like to use NextAuth with Firebase Authentication in my application, but I can't get around this issue. Thanks! |
Hey there, if you put this into your package.json it should work. "overrides": { |
This sort of works but then later on shows error when declaring adapter below:
TypeError: (0 , next_auth_firebase_adapter__WEBPACK_IMPORTED_MODULE_5_.default) is not a function |
Use npm install next-auth @next-auth/firebase-adapter@experimental |
Thank you for your answer!
But then I get the following error:
|
This has more to do with firestore security rules than NextJS. However, I feel that devs should go with Venkat’s approach and provide a fix through patch. Best Regards, Bhupendrasinh ThakreOn Nov 22, 2022, at 7:03 AM, Jorrit Willaert ***@***.***> wrote:
next-auth @***@***.***
Thank you for your answer!
I've tried this, with this in my [...nextauth].js file:
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { db } from "../../../firebase";
import { FirebaseAdapter } from ***@***.***/firebase-adapter";
import {
collection,
query,
getDocs,
where,
limit,
doc,
getDoc,
addDoc,
updateDoc,
deleteDoc,
runTransaction,
} from "firebase/firestore";
export const authOptions = {
// Configure one or more authentication providers
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
// ...add more providers here
],
secret: process.env.NEXTAUTH_SECRET,
adapter: FirebaseAdapter({
db,
collection,
query,
getDocs,
where,
limit,
doc,
getDoc,
addDoc,
updateDoc,
deleteDoc,
runTransaction,
}),
// The standard next auth page is this:
// theme: {
// logo: "https://links.papareact.com/sq0",
// brandColor: "#f13287",
// colorScheme: "auto",
// },
pages: {
signIn: "/auth/signin",
},
callbacks: {
async session({ session, token, user }) {
session.user.username = session.user.name
.split(" ")
.join("")
.toLowerCase();
session.user.uid = token.sub; // Google's user ID
return session;
},
},
};
export default NextAuth(authOptions);
But then I get the following error:
https://next-auth.js.org/errors#adapter_error_getsessionanduser Missing or insufficient permissions. {
message: 'Missing or insufficient permissions.',
stack: 'FirebaseError: Missing or insufficient permissions.',
name: 'FirebaseError'
}
[next-auth][error][SESSION_ERROR]
https://next-auth.js.org/errors#session_error Missing or insufficient permissions. [FirebaseError: Missing or insufficient permissions.] {
name: 'GetSessionAndUserError',
code: 'permission-denied'
}
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
When i try to do this, import { FirebaseAdapter } from "@next-auth/firebase-adapter"; it gives me an error that says @next-Auth has no exported member FirebaseAdapter did you mean FirestoreAdapter? How do i fix this issue? I am using typescript for my project. |
FirebaseAdapter is not working currently, no matter what we try. Will have to wait for next update. |
I even tried previous versions. |
Please refrain from calling out/mass tagging maintainers, it is not helpful for the discussion and only create hostility. Do note that most of us work on this project in their free time and should be no expectations from anyone working more on it than what their life situation can support. As several people pointed out earlier, downgrading did work #5551 (comment) so there was no imminent issue. Furthermore, given this is a open source project with a very forgiving license, you can copy and paste the source code, create your fork, etc. if you are not satisfied with the maintenance. I'm locking this thread to avoid being too heated, but please have another(?) look at our code of conduct https://github.com/nextauthjs/next-auth/blob/main/CODE_OF_CONDUCT.md before landing another comment like the above. Thanks. 💚 |
The fix is out in |
Thanks @balazsorban44 much appreciated. Will try this tonight |
One quick question folks. Do we need to change security rules in the firestore rules. Any one has done it yet and want to share their insights |
import NextAuth from "next-auth" export default NextAuth({ adapter: FirebaseAdapter({ This is my code, but its still giving an error on line 3 that, nextauth has no exported member FirebaseAdapter did you mean FirestoreAdapter? I upgraded the package to firebase adapter@1.0.3 but the issue still persists. I am using firebase version 9.10.0 and typescript in my project. What am i doing wrong here? |
|
@vedantmgoyal2009 i did as you said it, changed adapter:FirebaseAdapter to adapter:FirestoreAdapter but it now highlights the next line i.e. "db" and throws the following error:
What do i do now? |
[...nextauth].zip |
hey @vedantmgoyal2009 any updates? |
No bro |
@so-uvik I'm no longer using next-auth, and also, major changes have been introduced. I hope you'll be able to find a solution on internet. |
Adapter type
@next-auth/firebase-adapter
Environment
System Information.
Reproduction URL
https://github.com/bcthakre/nextjs-nextauth-2.git
Describe the issue
I am trying to use the FirebaseAdapter and Firestore to store user information for my NextJS app. However, getting the following error.
The issue was raised earlier but has not been fully resolved. Things I tried.
How to reproduce
Copy the github link as well.
[https://github.com/bcthakre/nextjs-nextauth-2.git]
Expected behavior
Should allow to store user and session information in Firestore. Also, need to provide a way to signIn and signOut
The text was updated successfully, but these errors were encountered: