firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.75k stars 872 forks source link

Line OpenID signInWithRedirect, "Unable to process request due to missing initial state" error, on iPhone only. #7946

Closed loibucket closed 1 month ago

loibucket commented 4 months ago

Operating System

IOS 17.1.2

Browser Version

Chrome 120.0.6099.119, Safari IOS 17.1.2

Firebase SDK Version

10.7.1

Firebase SDK Product:

Auth

Describe your project's tooling

React App

Describe the problem

I have setup firebase to host a react app, with a custom domain. I added LINE as an openid auth provider. The sign in process works fine on my mac chrome browser, my android chrome browser. But on my iPhone, I get the "Unable to process request due to missing initial state error" vqXKzzXuQDe5y-E_nPlg-Q

Steps and code to reproduce issue

import { useContext, createContext, useState, useEffect } from "react"; import { OAuthProvider, signInWithRedirect, onAuthStateChanged, signOut, } from "firebase/auth"; import { auth } from "../firebase"; const AuthContext = createContext(); export const AuthContextProvider = ({ children }) => { const provider = new OAuthProvider("oidc.line"); provider.addScope("openid"); const [user, setUser] = useState({}); const authSignIn = () => { signInWithRedirect(auth, provider); }; const logOut = () => { signOut(auth); }; useEffect(() => { const doThis = onAuthStateChanged(auth, (currentUser) => { setUser(currentUser); console.log(currentUser); }); return () => { doThis(); }; }, []); return ( <AuthContext.Provider value={{ authSignIn, logOut, user }}> {children} </AuthContext.Provider> ); }; export const useAuth = () => useContext(AuthContext);

Xiaoshouzi-gh commented 4 months ago

I'm assuming you are using the Safari browser when you opening the link on iOS device. Safari browser has enabled 3rd party storage partitioning starting 16.1 which cause the missing initial state issue. Please take a look on the redirect-best-practice doc where we suggested several ways that you can fix this.

google-oss-bot commented 1 month ago

Hey @loibucket. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 1 month ago

Since there haven't been any recent updates here, I am going to close this issue.

@loibucket if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.