Hello,
I am trying to use the ROPC flow to get back an ID token and authenticate a user against a B2C tenant. I have basic understanding of Azure. I am following the steps mentioned here:-
https://docs.microsoft.com/en-us/azure/active-directory-b2c/add-ropc-policy?tabs=app-reg-ga&pivots=b2c-user-flow
However, I get the following message back from Azure:-
{"error":"unauthorized_client","error_description":"AADB2C90248: Resource owner flow can only be used by applications created through the B2C admin portal.
I have pasted the code snippet I am using. Any insights into why this isn't working will help. Is there something in Azure I need to set?
try {
HttpClient httpclient = new DefaultHttpClient();
//HttpPost httppost = new HttpPost("https://devgrinnellmutualagents.b2clogin.com/devgrinnellmutualagents.onmicrosoft.com/B2C_1_ROPC_Auth/oauth2/v2.0/token");
HttpPost httppost = new HttpPost("https://devgrinnellmutualagents.b2clogin.com/devgrinnellmutualagents.onmicrosoft.com/B2C_1_ROPC_Auth/oauth2/v2.0/token");
try {
List<NameValuePair> nameValuePairs = new ArrayList<>();
//nameValuePairs.add(new BasicNameValuePair("username", "6000085170205300gm@dispostable.com"));
nameValuePairs.add(new BasicNameValuePair("username", "66000085170205300gm_dispostable.com#EXT#@devgrinnellmutualagents.onmicrosoft.com"));
nameValuePairs.add(new BasicNameValuePair("password", "testing123$$gm"));
nameValuePairs.add(new BasicNameValuePair("grant_type", "password"));
nameValuePairs.add(new BasicNameValuePair("scope", "openid 43872e67-4559-486f-88e3-bde0e6cc61fe"));
nameValuePairs.add(new BasicNameValuePair("client_id", "43872e67-4559-486f-88e3-bde0e6cc61fe"));
nameValuePairs.add(new BasicNameValuePair("response_type", "token id_token"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
String json_auth = EntityUtils.toString(response.getEntity());
System.out.println(json_auth);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception ex) {
ex.printStackTrace();
}