我一直在尝试使用MSAL将我的Android应用程序与Azure AD B2C集成,但我无法弄清楚如何使用自定义范围检索我的访问令牌。我使用this个MSAL样本作为参考。
我已经为我的应用程序授予了所需的权限,但我仍然收到此消息:
找不到范围的访问权限:https://rbxsoftb2c.onmicrosoft.com/rbx/get_access_token
这是我的Azure B2C设置,MSAL常量和我正在尝试访问的API:
MSAL常数:
public class Constants {
/* Azure AD b2c Configs */
final static String AUTHORITY = "https://login.microsoftonline.com/tfp/%s/%s";
final static String TENANT = "rbxsoftb2c.onmicrosoft.com";
final static String CLIENT_ID = "MY_CLIENT_ID";
final static String SCOPES = "https://rbxsoftb2c.onmicrosoft.com/rbx/get_access_token";
final static String API_URL = "https://rbxsoft.azurewebsites.net/api/values";
final static String SISU_POLICY = "B2C_1_SiUpIn";
final static String EDIT_PROFILE_POLICY = "B2C_1_edit_profile";
}
我的API:
[Produces("application/json")]
[Route("api/Values")]
[Authorize]
public class ValuesController : Controller
{
CosmosDatabaseConnection cdc = CosmosDatabaseConnection.Instance;
// GET: api/Values
[HttpGet]
public JValue Get()
{
AppState appState = SessionManager.GetCookieSession(HttpContext.Session, User);
return new JValue ( appState.User.profile.ToString() );
}
}