Trending

#authjs

Latest posts tagged with #authjs on Bluesky

Latest Top
Trending

Posts tagged #authjs

📝 New blog post
"3 Pitfalls of Multi-Portal Authentication with Keycloak [Part 5]"
ko-chan.github.io/saru-blog/posts-en/saru-...
#Keycloak #Authentication #Nextjs #Authjs #Multitenant

1 0 0 0

📝 ブログ記事を投稿しました
"Keycloakマルチポータル認証の3つの落とし穴 [第5回]"
zenn.dev/ko_chan/articles/saru-ke...
#Keycloak #Authentication #Nextjs #Authjs #Multitenant

2 0 0 0
Preview
How to Add User Authentication to Next.js with Auth.js - Teron Bullock So, you want to add authentication to your Next.js app and figured Auth.js might be the right tool; however, you’re not sure how to get started. No problem. In this post, I’ll break down the steps to ...

Want to add user authentication to your Next.js app?

I just dropped a walkthrough using Auth.js (formerly NextAuth.js) with TypeScript, covering login, secure routes & more.

teronbullock.com/how-to-add-u...

#Nextjs #Authjs #React #TypeScript #100Devs #SoftwareEngineer #CodingJourney

3 0 0 0
Preview
🚀 Criando o meu Projeto de Portfólio pessoal com Deploy na AWS! E aí, devs! Hoje falo um pouco mais sobre o projeto que estou criando que envolve desenvolvimento...

🚀 Criando o meu Projeto de Portfólio pessoal com Deploy na AWS! E aí, devs! Hoje falo um pou...

dev.to/marcelomagario/criando-o...

#aws #deploy #authjs #cms

Result Details

0 0 0 0
Preview
How to Fix LinkedIn Authentication in NextAuth.js: A Custom Provider Setup Guide ## A Quick Guide to Getting LinkedIn OAuth Working Correctly LinkedIn authentication is a powerful feature to add to your Next.js application using **NextAuth.js** , but the default configuration can often lead to issues — especially when trying to fetch user details like email, name, and profile picture. In this article, I’ll walk you through how I solved this issue by customizing the LinkedIn provider configuration in NextAuth.js. ## 🧪 The Problem Using the default `LinkedInProvider` setup from `next-auth/providers/linkedin` may not always return complete user information such as email or profile picture. ### 🔧 Default Implementation import LinkedInProvider from "next-auth/providers/linkedin"; providers: [ LinkedInProvider({ clientId: process.env.LINKEDIN_CLIENT_ID, clientSecret: process.env.LINKEDIN_CLIENT_SECRET, }) ] This basic setup often results in incomplete data being returned from LinkedIn. ## ✅ The Fix To overcome this, I had to dig into LinkedIn’s OAuth docs and customize the `LinkedInProvider` to manually specify scopes, endpoints, and userinfo configurations. ### 💡 Working LinkedInProvider Configuration LinkedInProvider({ clientId: process.env.LINKEDIN_CLIENT_ID ?? "", clientSecret: process.env.LINKEDIN_CLIENT_SECRET ?? "", client: { token_endpoint_auth_method: "client_secret_post" }, scope: "r_liteprofile r_emailaddress", issuer: "https://www.linkedin.com", userinfo: { url: "https://api.linkedin.com/v2/userinfo", }, token: { url: "https://www.linkedin.com/oauth/v2/accessToken", }, wellKnown: "https://www.linkedin.com/oauth/.well-known/openid-configuration", authorization: { url: "https://www.linkedin.com/oauth/v2/authorization", params: { scope: "profile email openid", prompt: "consent", access_type: "offline", response_type: "code", }, }, jwks_endpoint: "https://www.linkedin.com/oauth/openid/jwks", async profile(profile) { return { id: profile.sub, name: profile.name, firstname: profile.given_name, lastname: profile.family_name, email: profile.email, image: profile.picture, }; }, }), This configuration ensures you: * Request proper scopes like `r_emailaddress` * Use the correct LinkedIn OAuth endpoints * Get a complete `profile` object including email and picture ## 🔐 Bonus Tip: Twitter Provider Email Issue If you're using **Twitter authentication** as well, make sure you **enable email access** in your Twitter app settings. Without this, you won’t get the user’s email address. TwitterProvider({ clientId: process.env.TWITTER_CLIENT_ID, clientSecret: process.env.TWITTER_CLIENT_SECRET, }) > ✅ **Tip:** Enable "Request email address from users" in Twitter Developer Portal. ## 🧵 TL;DR * Default `LinkedInProvider` doesn’t return complete user info. * Customize it with the right OAuth config to fix it. * Twitter requires email permission to return user emails. Thanks for reading! 🚀 If you found this helpful, consider following me on Twitter and checking out my other projects like Resume Builder. Let me know if you’ve faced similar issues or need help with OAuth in your apps! 💬
0 0 0 0
Preview
Testing NextAuth.js Logins in Cypress: Optimizing Speed & Reliability ## Login Strategies for Cypress Tests In this article, I will demonstrate different approaches to handling authentication in your Cypress tests when using the NextAuth.js credentials provider. We will cover different methods for balancing test reliability with execution speed. In our examples, we will use a standard email/password login form, authenticating with a hard-coded test user (user@example.com) configured in the NextAuth.js Credentials Provider. // /auth.config.js import CredentialsProvider from "next-auth/providers/credentials"; export const authConfig = { providers: [ CredentialsProvider({ name: "Credentials", async authorize(credentials) { const user = { id: "1", password: "123", email: "user@example.com" }; return credentials.email === user.email && credentials.password === user.password ? user : null; }, }), ], pages: { signIn: "/login" }, }; // /app/page.js "use client"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; import { useState } from "react"; export default function LoginPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const router = useRouter(); const handleSubmit = async (e) => { e.preventDefault(); const result = await signIn("credentials", { email, password, redirect: false, }); result?.ok && router.refresh(); }; return ( <form onSubmit={handleSubmit}> <h1>Login</h1> <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Email" /> <input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="Password" /> <button type="submit">Login</button> </form> ); } The simplest and often correct approach is UI-based logins, as they accurately reflect real user behavior and are ideal for end-to-end (E2E) testing. However, if your test suite includes many tests that require authentication, UI-based repeated logins can significantly slow down execution. Below, I will cover several optimization techniques when using NextAuth.js with the credentials provider. // /cypress/e2e/login.cy.js describe("Login", () => { const credentials = { email: "user@example.com", password: "123", }; // 1. UI Login // Pros: Tests real user journey end-to-end // Cons: Requires full render cycle it("logs in via UI", () => { cy.visit("/"); cy.contains("Not logged in"); cy.get('[type="email"]').type(credentials.email); cy.get('[type="password"]').type(credentials.password); cy.get("button").contains("Login").click(); cy.contains(`Logged in as ${credentials.email}`).should("be.visible"); }); // 2. Direct API Request Login // Pros: Fastest method, bypasses UI // Cons: Doesn't test actual user flow it("logs in via direct API request", () => { cy.visit("/"); cy.contains("Not logged in"); cy.request({ method: "GET", url: `/api/auth/csrf`, }).then((csrfResponse) => { return cy.request({ method: "POST", url: `/api/auth/callback/credentials`, headers: { "Content-Type": "application/json" }, body: { ...credentials, csrfToken: csrfResponse.body.csrfToken, json: "true", }, }); }); cy.visit("/"); cy.contains(`Logged in as ${credentials.email}`).should("be.visible"); }); // 3. Browser Fetch API Login // Pros: Tests auth in browser context with real fetch API // Cons: More complex than cy.request, still skips UI it("logs in via browser fetch API", () => { cy.visit("/"); cy.contains("Not logged in"); cy.window().then(async (win) => { const csrfResponse = await win.fetch("/api/auth/csrf"); const { csrfToken } = await csrfResponse.json(); const loginResponse = await win.fetch("/api/auth/callback/credentials", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...credentials, csrfToken, json: "true" }), }); return loginResponse.json(); }); cy.visit("/"); cy.contains(`Logged in as ${credentials.email}`).should("be.visible"); }); // 4. Eval-Based Login // Pros: Demonstrates string injection technique // Cons: Least readable, potential security concerns // Use Case: Only needed when testing code evaluation scenarios it("logs in via eval-based approach", () => { cy.visit("/"); cy.contains("Not logged in"); cy.window().then((win) => { return win.eval(` (() => { const credentials = ${JSON.stringify(credentials)}; return fetch('/api/auth/csrf') .then(r => r.json()) .then(({ csrfToken }) => fetch('/api/auth/callback/credentials', { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...credentials, csrfToken, json: "true" }) }) ) .then(res => res.json()) })() `); }); cy.visit("/"); cy.contains(`Logged in as ${credentials.email}`).should("be.visible"); }); }); For most projects, you'll primarily use either UI login (for full end-to-end tests) or API login (for faster tests). The other methods are just examples. To make testing easier, move your login code into Cypress custom commands - this way you can reuse the same login logic across all your tests, keeping them clean and simple. // /cypress/support/commands.js Cypress.Commands.add("signIn", (email, password) => { cy.request("/api/auth/csrf").then((response) => { return cy.request({ method: "POST", url: "/api/auth/callback/credentials", body: { email, password, csrfToken: response.body.csrfToken, json: "true", }, }); }); cy.visit("/"); cy.contains(`Logged in as ${email}`).should("be.visible"); }); Now you can reuse the login command across all your tests it('logs in via custom command', ()=> { cy.signIn('user@example.com', '123') }) Hope this helps! Full code example: https://github.com/AlekseevArthur/next-auth-cypress
0 0 0 0
Post image

🚀🔐 My NextAuth.js v5 Prototype in Next.js!

🔗 Live Demo: next-auth-prototype.vercel.app
🔗 GitHub Repo: github.com/aladin002dz/...
📌 Server-side authentication (but error handling feels immature)
📌 Google OAuth integration
#React #NextJS #NextAuth #AuthJS #OAuth #TailwindCSS

1 0 0 0
Video

Introducing WordSphere My latest blog platform built with Next.js, Sanity, Clerk authentication, and Sentry for monitoring!
#Nextjs #webdeveloper #Typeescript #clerk #sentry #programmer #authjs #javascript #singlepageapplication #blogs

3 0 0 0

#NextAuth was a game changer for me.

Spent ages stuck on access/refresh tokens until NextAuth (now AuthJS?) broke the cycle. It clarified everything and helped me build my own #FastAPI auth server.

Nothing but respect for the #AuthJS devs and their patience on GH issues 🙌

2 0 1 0

Cet aprem j'ai laissé tomber firebase et et j'ai enfin compris qu'il me manquait juste un #adapter pour faire le lien entre mon implem #authjs actuelle et un query builder. Je suis partie sur #prisma en suivant un article sur Medium, avec un petit fichier #sqlite pour démarrer.

0 0 0 0