简体   繁体   中英

Azure B2C Using MSAL - Signup page not visible

I used the MSAL library for Android by referring the implementation : Azure AD B2C Sample but I don't see the login page. I did entered the correct details in Constants file

public final static String TENANT = "eventsapp.onmicrosoft.com";
public final static String CLIENT_ID = "XXXX-XXXX-XXXX-XXXX-XXXXXXX";

public final static String SISU_POLICY = "B2C_1_signin"; // my SISU policy name
public final static String EDIT_PROFILE_POLICY = "B2C_1_edit_profile";

public final static String AUTHORITY = "https://myapp.b2clogin.com/tfp/" + TENANT + "/" + SISU_POLICY; // myapp is a placeholder

And in Main Activity :

private String[] SCOPES = {"user.read"};

PublicClientApplication publicClientApplication = new PublicClientApplication(
                this.getApplicationContext(),
                Constants.CLIENT_ID,
                Constants.AUTHORITY);

publicClientApplication.acquireToken((Activity) context, SCOPES, getAuthInteractiveCallback());

Added libs in build.gradle :

implementation 'com.android.volley:volley:1.1.1'
implementation 'com.microsoft.identity.client:msal:0.3.+'

Where requesting for token all I see is a blank page. I copied the URL and pasted in browser and it gives nothing. But when tested using the user flow in Azure portal it works.

Any help please ?

User.Read is in an invalid scope for AAD B2C, its referring to Graph API. So the page is likely just throwing an error back to the app, hence the customer doesn't see it.

They need to follow the following, which creates an App Reg to represent a resource (web api), and then publish a scope on this App Reg. Then on the Android App Reg, they need to add the scope to its permissions:

https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-tutorials-desktop-app-webapi

Then in the app, this
private String[] SCOPES = {"user.read"};

Should look like this instead
private String[] SCOPES = {"https://contosotenant.onmicrosoft.com/api/permissionName"};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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