I'm trying to implement authentication with Microsoft using Firebase in my app. I followed the steps mentioned in the tutorial https://firebase.google.com/docs/auth/android/microsoft-oauth.
Following are the code snippets from my application -
MSAuthManager.java
public void loginOutlook(Context context) {
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
Task<AuthResult> pendingResultTask = firebaseAuth.getPendingAuthResult();
if (pendingResultTask == null) {
OAuthProvider.Builder provider = OAuthProvider.newBuilder("microsoft.com");
provider.setScopes(asList(SCOPES));
firebaseAuth.startActivityForSignInWithProvider((Activity) context, provider.build())
.addOnSuccessListener(this)
.addOnFailureListener(this)
.addOnCanceledListener(this);
}
}
AndroidManifest.xml
<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https://**********.firebaseapp.com/__/auth/handler"
android:host="auth" />
</intent-filter>
</activity>
Note - I have already authenticated the user with Google sign-in using Firebase on the Login Screen.
However, when I start the authentication process, a custom tab launches takes me to the Microsoft login page and then automatically closes and redirects me back to my app with the following error -
FirebaseAuthWebException: The web operation was canceled by the user.
Could anyone please tell me what am I missing here?