Home > Enterprise >  Firebase auth v9 - AuthCredential.fromJSON() disappeared
Firebase auth v9 - AuthCredential.fromJSON() disappeared

Time:06-12

In the system I work on, there is a auth-web-app which is used to authenticate a user, serializes credential, and then transfer it by message to another app. The other app receives the credential, parse it, and pass it to its own firebase-auth package to authenticate user inside its process.

In Firebase v8, AuthCredential had a static function fromJSON() which was used by the receiver app of the credential to parse it.

But in Firebase v9, this function has disappeared. There no more fromJSON() function in in AuthCredential. There's only a toJSON() function.

How can I parse the json representation into a AuthCredential instance with v9?

CodePudding user response:

You can now use OAuthCredential class that extends AuthCredential in V9.

import { OAuthCredential } from "firebase/auth";

const cred = OAuthCredential.fromJSON('{...}')
  • Related