Closed vikasbo closed 4 years ago
@vikasbo You are wrong with the project. This issue has to report into https://github.com/AzureAD/microsoft-authentication-library-for-java
@vikasbo @msize I looked into this and this as bug in the partner center SDK (although MSAL should do a better job of validating authorities and throwing an useful error message in this case - https://github.com/AzureAD/microsoft-authentication-library-for-java/issues/180).
The reason this is happening is because when instantiating
IPartnerCredentials appCredentials =
PartnerCredentials.getInstance()
.generateByApplicationCredentials(clientId, applicationSecret, aadApplicationDomain)
Partner center sets activeDirectoryAuthority to "https://login.microsoftonline.com/". Then when passing in the authority to MSAL it adds another trailing slash before adding the aadApplicationDomain
. So the authority that gets passed in is "https://login.microsoftonline.com//aadApplicationDomain" which is invalid. It should actually be "https://login.microsoftonline.com/aadApplicationDomain"
If you confirm that this is the issue, I'll see if I can submit a PR at some point this week.
This was not clear from the first comment. There was only a stack trace from the msal4j component.
As a workaround, the fix which removes the last slash may be fixed the problem. But, I'm don't sure that the msal4j don't remove the first slash from them code somewhen in the future too. And this workaround can produce a new problem.
Therefore, I'd don't make this workaround in the main branch of the PC SDK.
@msize I'm not sure what you mean by "But, I'm don't sure that the msal4j don't remove the first slash from them code somewhen in the future too. And this workaround can produce a new problem". Can you please explain?
Partner center SDK is passing the wrong value in to msal4j for authority. As long as this is not fixed in partner SDK, this API (PartnerCredentials.getInstance() .generateByApplicationCredentials(clientId, applicationSecret, aadApplicationDomain)
) will always fail. Therefore this logic should probably to be fixed in the master branch and released.
@msize @sangonzal Based on your comments above, I believe the bug is in two folds:
MSAL must throw an understandable error message instead of throwing the run time error i.e. ArrayIndexOutOfBoundsException
. Run time errors are a good sign that some validation is missing
The Partner center should not be initializing the authority with an extra slash '/' which is being added by MSAL anyways. Therefore, it should initialize with "https://login.microsoftonline.com" instead of "https://login.microsoftonline.com/".
I would consider it a bug in both the projects because even if MSAL was to send a readable/actionable error, the extra slash causing the run time error of ArrayIndexOutOfBoundsException
will not be fixed/removed by any code changes of clients using Partner Center and MSAL as its dependency.
A quick fix for the above bug in Partner Center would be highly appreciated.
@msize Thank you for this. Please share an ETA for this since it is a blocking issue. Thanks.
Steps to reproduce
throws:
Expected behavior
The above error does not make sense. Same code, same credentials worked in the previous version 1.5.1 but suddenly not working on switching to 1.5.3 latest build.
What could be the change that caused this and what is the root cause that can be attributed to the ArrayIndexOutOfBoundsException.
Actual behavior
Diagnostic logs
Environment