Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use react-native-firebase/auth OAuth provider to auth Azure AD credential

I am developing a mobile with react-native (react-native-firebase/auth) and using Firebase Auth to manage user login. In the beginning, I only use the email/password to auth users and work nice.

Now I would like to let users use Azure AD. Since react-native-firebase/auth does not support Microsoft account at this moment, so I use react-native-app-auth. Afterwards, use the Microsoft credential to auth the Firebase user and link them together.

const result = await authorize(config);
const credential = auth.OAuthProvider.credential(
  result.idToken,
  result.accessToken,
);
const userCredential = await auth().signInWithCredential(credential);

When calling the signInWithCredential, it throw an error : [auth/internal-error].

Currently, I have backend user profile like to a Firebase user account. I don't want to complicate the backend to have multiple auth methods. Ideally, it can be done at the Firebase would be great.

Thanks.

like image 932
Raymond Avatar asked Apr 02 '20 10:04

Raymond


People also ask

Can Firebase integrate with Azure?

You can let your users authenticate with Firebase using OAuth providers like Microsoft Azure Active Directory by integrating generic OAuth Login into your app using the Firebase SDK to carry out the end to end sign-in flow.


1 Answers

Seems like you have to use a custom token.

Unlike other OAuth providers supported by Firebase such as Google, Facebook, and Twitter, where sign-in can directly be achieved with OAuth access token based credentials, Firebase Auth does not support the same capability for providers such as Microsoft due to the inability of the Firebase Auth server to verify the audience of Microsoft OAuth access tokens.

If these providers are required to be used in unsupported environments, a third party OAuth library and Firebase custom authentication would need to be used.

source: Firebase doc

like image 88
Gabriel Bleu Avatar answered Oct 20 '22 19:10

Gabriel Bleu