简体   繁体   English

带有 Microsoft 错误的 Firebase 身份验证

[英]Firebase authentication with Microsoft error

I'm trying to implement Firebase Authentication on my Android app for my organization.我正在尝试在我的组织的 Android 应用程序上实施 Firebase 身份验证。 Every employee has a Microsoft business account so I want to use that email/password to sign in on my app.每个员工都有一个 Microsoft 企业帐户,因此我想使用该电子邮件/密码登录我的应用程序。

I enabled this option on the Firebase Console and filled data with the information of the Azure AD application I created:我在 Firebase 控制台上启用了这个选项,并用我创建的 Azure AD 应用程序的信息填充数据:

在此处输入图片说明

The Azure AD app has the permission to log in users and read their profile. Azure AD 应用程序有权登录用户并读取他们的个人资料。

在此处输入图片说明

I managed to get it working to the point where the users are created on my Firebase Console.我设法让它工作到在我的 Firebase 控制台上创建用户的程度。

在此处输入图片说明

But on my Android app, after writing the credentials, this error message appears.但是在我的 Android 应用程序上,写入凭据后,会出现此错误消息。

We're having trouble signing you in. AADSTS900561: The endpoint only accepts POST requests.我们在为您登录时遇到问题。 AADSTS900561:端点只接受 POST 请求。 Received a GET request.收到 GET 请求。

在此处输入图片说明

The Android code is the sample code Firebase gives. Android 代码是 Firebase 提供的示例代码。

OAuthProvider.Builder provider = OAuthProvider.newBuilder("microsoft.com");

Task < AuthResult > pendingResultTask = mAuth.getPendingAuthResult();
if (pendingResultTask != null) {
    pendingResultTask.addOnSuccessListener(new OnSuccessListener < AuthResult >
        () {
            @Override
            public void onSuccess(AuthResult authResult) {
                Log.e("PROFILE", authResult.getAdditionalUserInfo()
                    .getProfile().toString());
            }
        }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.e("FAIL", "ERROR LOGIN");
        }
    });
} else {
    mAuth.startActivityForSignInWithProvider(Login.this, provider.build())
        .addOnSuccessListener(new OnSuccessListener < AuthResult > () {
            @Override
            public void onSuccess(AuthResult authResult) {
                Log.e("PROFILE", authResult.getAdditionalUserInfo()
                    .getProfile().toString());
                Log.w("USERNAME", authResult.getUser()
                    .getDisplayName());

            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.e("FAIL", "ERROR LOGIN: " + e);
            }
        });
}

The PROFILE logline is being printed and there are no errors in Android Studio.正在打印PROFILE日志行并且 Android Studio 中没有错误。 Also if the user is being created on Firebase...I don't know what's causing the login process not to be completed.此外,如果用户是在 Firebase 上创建的……我不知道是什么导致登录过程无法完成。

EDIT: This is my redirect URI configuration on Azure AD app:编辑:这是我在 Azure AD 应用程序上的重定向 URI 配置:

在此处输入图片说明

EDIT 2: The supported account type is set to all accounts.编辑 2:支持的帐户类型设置为所有帐户。 (It's in Spanish sorry, it says I can edit the manifest to change the configuration) (它是西班牙语,抱歉,它说我可以编辑清单以更改配置)

在此处输入图片说明

The manifest looks like this:清单如下所示:

{
  "id": "******************************",
  "acceptMappedClaims": null,
  "accessTokenAcceptedVersion": 2,
  "allowPublicClient": null,
  "appId": "***************************",
  "appRoles": [],
  "oauth2AllowUrlPathMatching": false,
  "createdDateTime": "2019-04-02T09:53:53Z",
  "groupMembershipClaims": null,
  "identifierUris": ["api://****************************"],
  "informationalUrls": {
    "termsOfService": null,
    "support": null,
    "privacy": null,
    "marketing": null
  },
  "keyCredentials": [],
  "knownClientApplications": [],
  "logoUrl": null,
  "logoutUrl": null,
  "name": "App name",
  "oauth2AllowIdTokenImplicitFlow": true,
  "oauth2AllowImplicitFlow": true,
  "oauth2Permissions": [],
  "oauth2RequirePostResponse": false,
  "optionalClaims": null,
  "orgRestrictions": [],
  "parentalControlSettings": {
    "countriesBlockedForMinors": [],
    "legalAgeGroupRule": "Allow"
  },
  "passwordCredentials": [
    {
      "customKeyIdentifier": null,
      "endDate": "2099-12-31T12:00:00Z",
      "keyId": "***************************",
      "startDate": "2019-04-02T09:55:10.2084897Z",
      "value": null,
      "createdOn": "2019-04-02T09:55:14.432352Z",
      "hint": "gGL",
      "displayName": null
    }
  ],
  "preAuthorizedApplications": [],
  "publisherDomain": "domain.com",
  "replyUrlsWithType": [
    {
      "url": "https://***********.firebaseapp.com/__/auth/handler",
      "type": "Web"
    },
    {
      "url": "https://login.live.com/oauth20_desktop.srf",
      "type": "InstalledClient"
    },
    {
      "url": "urn:ietf:wg:oauth:2.0:oob",
      "type": "InstalledClient"
    },
    {
      "url": "https://login.microsoftonline.com/common/oauth2/nativeclient",
      "type": "InstalledClient"
    },
    {
      "url": "msalececeef1-*****************://auth",
      "type": "InstalledClient"
    }
  ],
  "requiredResourceAccess": [
    {
      "resourceAppId": "*************************",
      "resourceAccess": [
        {
          "id": "***********************",
          "type": "Scope"
        }
      ]
    }
  ],
  "samlMetadataUrl": null,
  "signInUrl": null,
  "signInAudience": "AzureADandPersonalMicrosoftAccount",
  "tags": [],
  "tokenEncryptionKeyId": null
}

I've tried changing the "oauth2RequirePostResponse": false to true but it didn't work either.我尝试将"oauth2RequirePostResponse": false更改为true但它也不起作用。

Tried to check the token check-boxes under Manage -> Authentication?尝试检查管理 -> 身份验证下的令牌复选框? For me that was the difference对我来说这就是区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM