目次
Supabaseを使った認証機能をNext.jsで開発していたところ「Invalid login credentials」エラーでつまづいたので、私と同じ現象が起きている人の役に立てればと思い記事にしました。
Invalid login credentials
No API key found in request
const { data, error } = await supabase.auth.signInWithPassword({
email: "test@example.com",
password: "password123",
});
if (error) {
console.error("Login error:", error.message);
}
Invalid login credentials
が表示されるNo API key found in request
というエラーも発生supabase
クライアントが統一されているか?supabaseClient.js
で createClient
しているか?import { createClient } from "@supabase/supabase-js";
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
signUp()
と signInWithPassword()
で異なるクライアントを使用していないか確認Project Settings
→ Authentication → Password settings in email provider
→ Email
→ Confirm email
から確認デフォルトの確認メール
{
"error": "Invalid login credentials"
}
const { data, error } = await supabase.auth.signUp({
email: "test@example.com",
password: "password123",
});
if (error) {
console.error("Signup error:", error.message);
} else {
console.log("Check your email to confirm your account");
}
Invalid login credentials
のエラーは メール未確認 が主な原因