Azure B2C UWP:WebAuthenticationBroker回调URL未触发

时间:2016-12-07 12:43:06

标签: uwp azure-ad-b2c

我们正在将Azure B2C与Universal Windows应用程序中的IdentityModel.OidcClient插件集成

IdentityModel.OidcClient为UWP应用程序编写了示例,它将打开WebView进行登录。

WebView使用WebAuthenticationBroker类编写。

我们能够将Azure B2C端点与IdentityModel插件集成,并使用WebAuthenticationBroker在webview中打开Azure B2C STS页面。

wabResult = await WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None, new Uri(startURL), new Uri(options.EndUrl));
  

startURL指向Azure B2C,EndUrl指向回调URL(Azure B2C上的重定向URI)

当我们输入凭据Azure B2C时,将授权代码与state和id_token一起返回到redirecturi(回调URL)。但 WebAuthenticationBroker 无法识别重定向的网址。以下是Azure B2C返回的示例片段。

#state=922d93b9c7935175dd17fee724b97cbe950feb28770b8d4c03e7cb18f92acf1f663d61139c8d063876f7206e4a67a826a092d69940ea20616c1336560ec3cd65&code=eyJraWQiOiJjcGltY29yZV8wOTI1MjAxNSIsInZlciI6IjEuMCJ9..UCwZR2rMfKUdD1tA.w_BzDy32MTa31vBEmOhvG-KB2UnY8qhIVRcDVXZFyULaqh7qMzk8G0ZeTnba6JEbJ7ww6jZ4uTl6trS6yPQKjP0ZxSQZZuKEDDy31jhQqFEaql___KTfPQymVbJyJSI6ctHeT823-Ziv4dz9I3NGcPmBgqu2yJxwTPOKTlPB_RCbaoj3oLrRqY26YKU4H61LpaMndsP95eIGmIrKClPGc8ntvrmijJymUpJiuUQRqYMkviC2gh2lVlereDWUUcfJG3QIlpAEyh2kIA7EAblcGZj55Yp0LDe4xpbDuW-oks1jhKnvE_eApjIlSstaOObKvQiKjBuds_qbQXCcY5hKktRxBklN3teF7LRhJdH0Yb22ks7PFA9JrB2gbsCJWk-PuUslep7eiX4WXFJ3MYn_t8j2djkUDeOzNw6vNgHxLTKSkClhLrFgONLKsZeh76W12D0YOXZ0Pxf8ceA7it2gxnW_1WqOUPtSaN2VSLDWejcJ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yODlkNTg5OGFkZmQ2NjM0NDAwYzg4ZTc5NWRkMzVkOTc2MDZmYTYzYzdhZWFlYTU2NTRiMTdjYjhmOTQ0MTVhNTgxNTc5OTZlZmQxNDVlNjgzYmExZWI0ODVjNTRmZTMyOTUyZDYiLCJpYXQiOjE0ODExMDk5MjMsImF1dGhfdGltZSI6MTQ4MTEwOTkyMywib2lkIjoiNDg4YTZlMDQtNjhhYi00OGZkLWExMGItMDIzMWIwOGEwYWYxIiwibmFtZSI6IlJhbWFrcmlzaG5hIFNDaGFrcmEiLCJleHRlbnNpb25fRGVmYXVsdEZlZWRUYWIiOiJUZWNoIE5ld3MiLCJ0ZnAiOiJCMkNfMV9iMmNfMV9zaWduX2luX3NpZ25fdXAiLCJjX2hhc2giOiJQd1hQYUpvenVORGpqWkZuZVMtMlFRIn0.AfTaIf_ax2uBBp5vnJH6khMyhvSsoRBzdgyi80tabcMCqFTq-SxwnivuEFrn-08Y3jihEj49Vhp5PUKMKMJ0JDgWUA-CrndGIFRJoZlwV9QglwAy7QqEJpelxiYKHrhfbmCLHwun80saII_KHMZAyUSHfJLkxBiRPxuIcnOeN9NtQi1N1AiPwihBC-dfNQDHzxqvUqfJmnwBMjb8ct-7pyPpy28GfyTpkHLqm4X-qKhS3LM9W9eR6zw4hkZKcW0Lny9tgstAYh9pjbaG0VME-9nyfs-zT7Z1Refs5tR1AlKfTL-bPoihTQTSQh5Zz9y-TSGSL1Bm2wp9i5e3Aa0U9Q

单独片段的长度超过3K

当我们中断Azure B2C返回的片段并将中断的片段发送回callbackurl时, WebAuthenticationBroker 能够重新调整URL并关闭webview并发送数据包。

中断的片段如:

#state=nostate&code=nocode&id_token=noidtoken

现在片段长度不超过100个字符, WebAuthenticationBroker 可以轻松地重新调整URL和片段,当它到达callbackurl时也关闭webview。

任何人都可以为此提供解决方法。

1 个答案:

答案 0 :(得分:0)

您可以减少声明数量,并且可能无法更改代码

MSDN - AAD B2C with UWP