Skip to content

Commit 68a9972

Browse files
authored
Use the dedicated admin consent endpoint instead of a query parameter (#599)
1 parent 290b543 commit 68a9972

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthorizationRequestUrlParameters.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public class AuthorizationRequestUrlParameters {
3434
private String correlationId;
3535
private boolean instanceAware;
3636

37+
//Unlike other prompts (which are sent as query parameters), admin consent has its own endpoint format
38+
private static final String ADMIN_CONSENT_ENDPOINT = "https://login.microsoftonline.com/{tenant}/adminconsent";
39+
3740
Map<String, List<String>> requestParameters = new HashMap<>();
3841

3942
public static Builder builder(String redirectUri,
@@ -155,7 +158,14 @@ URL createAuthorizationURL(Authority authority,
155158
Map<String, List<String>> requestParameters) {
156159
URL authorizationRequestUrl;
157160
try {
158-
String authorizationCodeEndpoint = authority.authorizationEndpoint();
161+
String authorizationCodeEndpoint;
162+
if (prompt == Prompt.ADMIN_CONSENT) {
163+
authorizationCodeEndpoint = ADMIN_CONSENT_ENDPOINT
164+
.replace("{tenant}", authority.tenant);
165+
} else {
166+
authorizationCodeEndpoint = authority.authorizationEndpoint();
167+
}
168+
159169
String uriString = authorizationCodeEndpoint + "?" +
160170
URLUtils.serializeParameters(requestParameters);
161171

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/Prompt.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ public enum Prompt {
2525
*/
2626
CONSENT("consent"),
2727

28-
/**
29-
* An administrator should be prompted to consent on behalf of all users in their organization.
30-
* <p>
31-
* Deprecated, instead use Prompt.ADMIN_CONSENT
32-
*/
33-
@Deprecated
34-
ADMING_CONSENT("admin_consent"),
35-
3628
/**
3729
* An administrator should be prompted to consent on behalf of all users in their organization.
3830
*/

0 commit comments

Comments
 (0)