简体   繁体   English

使用MSAL的Azure B2C -``注册''页面不可见

[英]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. 我通过参考实现使用了用于Android的MSAL库: Azure AD B2C示例,但没有看到登录页面。 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 : 在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. 我复制了URL并将其粘贴在浏览器中,但没有任何帮助。 But when tested using the user flow in Azure portal it works. 但是,在Azure门户中使用用户流进行测试时,它可以工作。

Any help please ? 有什么帮助吗?

User.Read is in an invalid scope for AAD B2C, its referring to Graph API. User.Read属于AAD B2C的无效范围,它引用的是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. 他们需要遵循以下步骤,即创建一个App Reg来表示资源(Web api),然后在此App Reg上发布范围。 Then on the Android App Reg, they need to add the scope to its permissions: 然后,在Android App Reg上,他们需要将范围添加到其权限中:

https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-tutorials-desktop-app-webapi https://docs.microsoft.com/zh-CN/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"};

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

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