android - 如何使用 Firebase 进行身份验证,在 Android 上使用 Microsoft
问题描述
在 Android 上使用 Microsoft 进行身份验证
最初,我能够进入身份验证页面(请参阅:登录),但是在没有更改代码的情况下,它似乎突然跳过或失败OnSuccessListener
,这导致身份验证页面最终失败并让我回到我的主页中MainActivity.java
看到:结果。
需要明确的是,我希望我正在使用的应用程序提示 Microsoft 登录,然后在成功/失败时,在那里做一些事情。Firebase Google 登录非常适合我。我觉得问题可能在于我如何将应用程序从 Firebase 重定向到 Azure AD。如果我单击第一个选项(我想要的),它仍然会失败,如果我完全删除我的 URI,我会收到一条错误消息,指出我正在尝试使用错误的应用程序进行身份验证,请参阅:URI。
错误:com.google.firebase.auth.firebaseAuthInvalidCredentialsException: The supplied auth credential is malformed or has expired. [Error getting access token from microsoft.com...]
我的应用程序 ID、机密和重定向 URI都与我在 Azure AD 中的内容匹配。错误
firebaseAuth
.startActivityForSignInWithProvider(/* activity= */ this, provider.build())
.addOnSuccessListener(
new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
// User is signed in.
// IdP data available in
// authResult.getAdditionalUserInfo().getProfile().
// The OAuth access token can also be retrieved:
// authResult.getCredential().getAccessToken().
// The OAuth ID token can also be retrieved:
// authResult.getCredential().getIdToken().
// openActivity2();
statusTextView.setText("Successfully authenticated with Microsoft.");
microsoftSignOutButton.setVisibility(microsoftSignOutButton.VISIBLE);
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Handle failure.
statusTextView.setText("Failed to load on Microsoft sign in.");
}
});
解决方案
推荐阅读
- html - 超过父身高时如何匹配兄弟身高
- r - 如何在 R 中使用共享参数执行非线性最小二乘?
- php - 在 Laravel 上保存后如何获取正确的 Id 参数
- css - 有没有办法在不使用 className 的情况下使用 ID 在 React 中设置元素的样式?
- c++ - constexpr 字符串文字检查:语法短,没有运行时的可能性
- javascript - Discord.js - CommandFile.Run() 不是函数
- docker - 使用热重载进行调试
- mysql - 将我的节点 js 应用程序从 heroku 连接到 Godaddy 上的 Mysql 数据库
- python - 在 Python 的 statsmodels 中从 rucm 复制受限的 s.level
- python - Python中最常见的删除单词和打印