我正在使用MSAL
. 目前我正在使用 createSingleAccountPublicClientApplication
我的应用程序。我已经创建sign-up and sign-in user flow
并与我的应用程序集成,它运行良好。当应用程序启动时,它会重定向到 Web 视图,因为我已经提到BrowserTabActivity
了清单文件的内部。但是根据我们的要求,我们必须创建自己的custom webview
并显示所有userflows
内容并根据需要获取回调。是否可以custom webview
为 android 创建并显示用户流?
第二个问题是,当用户back button
从 SignUp Page点按时AADB2C90091
,会抛出错误代码,而不是返回signIn
UserFlow Page 。如何在signIn
后按时显示 UserFlow 页面?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.microsoft_azure);
context = MicrosoftAzureActivity.this;
initializeUI();
// Creates a PublicClientApplication object with res/raw/auth_config_single_account.json
PublicClientApplication.createSingleAccountPublicClientApplication(MicrosoftAzureActivity.this,
R.raw.auth_config_single_account,
new IPublicClientApplication.ISingleAccountApplicationCreatedListener() {
@Override
public void onCreated(ISingleAccountPublicClientApplication application) {
/**
* This test app assumes that the app is only going to support one account.
* This requires "account_mode" : "SINGLE" in the config json file.
**/
mSingleAccountApp = application;
loadAccount();
}
@Override
public void onError(MsalException exception) {
displayError(exception);
}
});
}
负载帐户::
private void loadAccount() {
if (mSingleAccountApp == null) {
return;
}
mSingleAccountApp.getCurrentAccountAsync(new ISingleAccountPublicClientApplication.CurrentAccountCallback() {
@Override
public void onAccountLoaded(@Nullable IAccount activeAccount) {
// You can use the account data to update your UI or your app database.
mAccount = activeAccount;
if (activeAccount != null) {
mSingleAccountApp.acquireTokenSilentAsync(getScopes(), B2CConfiguration.getAuthorityFromPolicyName("B2C_1_SignInSignUp"), getAuthSilentCallback());
}
}
@Override
public void onAccountChanged(@Nullable IAccount priorAccount, @Nullable IAccount currentAccount) {
if (currentAccount == null) {
// Perform a cleanup task as the signed-in account changed.
showToastOnSignOut();
}
}
@Override
public void onError(@NonNull MsalException exception) {
displayError(exception);
}
});
}
auth_config_single_account::
{
"client_id" : "cfsttrtkg-4545-fsrdh-822d-53453423-0",
"redirect_uri" : "msauth://**********/***********,
"account_mode" : "SINGLE",
"broker_redirect_uri_registered": false,
"authorization_user_agent" : "WEBVIEW",
"authorities": [
{
"type": "B2C",
"authority_url": "SIGNIN_SIGNUP_POLICY",
"default": true
},
{
"type": "B2C",
"authority_url": "PASSWORD_RESET_POLICY"
}
]
}