ROPC流程尝试执行userrealm发现并失败

问题描述 投票:0回答:2

我正在尝试使用MSAL来使用B2C ROPC流获取访问令牌。但是,它未能尝试使用常规AAD(而非B2C)用户域发现,这显然会因用户ID没有域而失败。

Fiddler表明MSAL执行的一个调用是:https://login.microsoftonline.com/common/userrealm/user1?api-version=1.0。注意'user1',它是B2C中的有效用户ID但不是AAD中的有效用户ID。

            Authority = "https://login.microsoftonline.com/tfp/mrochonb2cprod.onmicrosoft.com/B2C_1_ROP/.well-known/openid-configuration";
            var pwd = new SecureString();
            foreach (var c in "...") pwd.AppendChar(c);
            var app = PublicClientApplicationBuilder
                .Create(ClientId)
                    .WithB2CAuthority(Authority)
                        .Build();
            var ar = await app.AcquireTokenByUsernamePasswordAsync(Scopes, "user1", pwd);
azure azure-ad-b2c
2个回答
1
投票

我已经与Microsoft工程师确认了这一点。目前他们没有使用B2C用户测试MSAL aquiretokenusernamepassword()方法,并且没有这样的样本。此功能已公开预览。他们使用AppAuth for iOS和AppAuth for Android在生产中广泛测试了这一流程。你可以找到更多细节hereenter image description here

但是ropc流程工作正常,你可以使用post请求。

POST /yourtenant.onmicrosoft.com/oauth2/v2.0/token?p=B2C_1_ROPC_Auth HTTP/1.1
Host: yourtenant.b2clogin.com
Content-Type: application/x-www-form-urlencoded

username=leadiocl%40trashmail.ws&password=Passxword1&grant_type=password&scope=openid+bef22d56-552f-4a5b-b90a-1988a7d634ce+offline_access&client_id=bef22d56-552f-4a5b-b90a-1988a7d634ce&response_type=token+id_token


{ 
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik9YQjNhdTNScWhUQWN6R0RWZDM5djNpTmlyTWhqN2wxMjIySnh6TmgwRlkifQ.eyJpc3MiOiJodHRwczovL3RlLmNwaW0ud2luZG93cy5uZXQvZjA2YzJmZTgtNzA5Zi00MDMwLTg1ZGMtMzhhNGJmZDllODJkL3YyLjAvIiwiZXhwIjoxNTEzMTMwMDc4LCJuYmYiOjE1MTM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mVudGx5LiBVc2Ugb2lkIGNsYWltLiIsImF1ZCI6ImJlZjIyZDU2LTU1MmYtNGE1Yi1iOTBhLTE5ODhhN2Q2MzRjZSIsImFjciI6ImIyY18xYV9yZXNvdXJjZW93bmVydjIiLCJpYXQiOjE1MTMxMjY0NzgsImF1dGhfdGltZSI6MTUxMzEyNjQ3OCwib2lkIjoiM2MzYjk2OWMtOGM0OS00ZTExLWE0ZWYtZmRiMmYzOTJmMDQ5IiwiYXRfaGFzaCI6Ikd6QUNCTVJtcklwYm9OdkFtNHhMWEEifQ.iAJg13cgySsdH3cmoEPGZB_g-4O8KWvGr6W5VzRXtkrlLoKB1pl4hL6f_0xOrxnQwj2sUgW-wjsCVzMc_dkHSwd9QFZ4EYJEJbi1LMGk2lW-PgjsbwHPDU1mz-SR1PeqqJgvOqrzXo0YHXr-e07M4v4Tko-i_OYcrdJzj4Bkv7ZZilsSj62lNig4HkxTIWi5Ec2gD79bPKzgCtIww1KRnwmrlnCOrMFYNj-0T3lTDcXAQog63MOacf7OuRVUC5k_IdseigeMSscrYrNrH28s3r0JoqDhNUTewuw1jx0X6gdqQWZKOLJ7OF_EJMP-BkRTixBGK5eW2YeUUEVQxsFlUg" 
}

0
投票

MSAL.NET v3.0.5-preview+使用ROPC流程与B2C合作。有关使用MSAL的更多信息,请参阅此section of the MSAL.NET wiki

© www.soinside.com 2019 - 2024. All rights reserved.