Skip to content

API Changes, deprecating all methods not using TokenParameters #1595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
500ba1c
Began deprecating methods, created SignInParameters class shell
fadidurah Feb 16, 2022
f5bef75
Implemented SignInParameters, finished SAPCA
fadidurah Feb 17, 2022
a8ff440
Restore javadocs
fadidurah Feb 22, 2022
e3b7d93
Implemented changes for MultipleAccountPCA
fadidurah Feb 22, 2022
9b539ec
Updated submodule
fadidurah Feb 22, 2022
67025bc
Added testing for SignInParameters
fadidurah Feb 23, 2022
836b4ce
Updated api ids in SAPCA. Updated submodule and some javadocs
fadidurah Mar 2, 2022
17239a4
Merge branch 'dev' into fadi/api-changes
fadidurah Mar 3, 2022
4842df2
Update sub module
fadidurah Mar 4, 2022
bffaf24
Update submodule
fadidurah Mar 11, 2022
78478f9
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
fadidurah Mar 11, 2022
a19a22c
fixed acquireTokenWithDeviceCode SCOPES annotation
fadidurah Mar 12, 2022
4bb8e5b
Fixed tests, new apiIds used in AcquireMockedTelemetryTest
fadidurah Mar 12, 2022
97bfdd0
Small change to rerun checks
fadidurah Mar 14, 2022
2d2a11c
restore change
fadidurah Mar 14, 2022
6df1eb7
Minor fixes to SignInParameters documentation
fadidurah Mar 15, 2022
76ad0f0
Update common
fadidurah Mar 15, 2022
881a821
Update changelog
fadidurah Mar 15, 2022
686a7d4
Small tweak to tests. Rerun checks
fadidurah Mar 16, 2022
b2971d1
Merge branch 'dev' into fadi/api-changes
fadidurah Mar 17, 2022
0cbf7cb
update common, add more flushScheduler() for SingleAccountOverloadsMo…
fadidurah Mar 17, 2022
2a99134
Merge branch 'fadi/api-changes' of https://github.com/AzureAD/microso…
fadidurah Mar 17, 2022
a1475f5
Removed flushSchedulers, there was a loop
fadidurah Mar 17, 2022
954945b
Rerun checks
fadidurah Mar 17, 2022
f8de870
Trigger Pipelines
fadidurah Mar 18, 2022
9aaecec
Attemptign fix with shadowof(getMainLooper()).idle()
fadidurah Mar 18, 2022
955f17e
Trigger Pipelines
fadidurah Mar 19, 2022
c2c16de
Trigger Pipelines
fadidurah Mar 19, 2022
be901cc
Trigger Pipelines
fadidurah Mar 19, 2022
d3e8049
test without testSignInOnlyAllowedOnceWithParameters
fadidurah Mar 19, 2022
20aab24
Placing tests in a different file
fadidurah Mar 21, 2022
ab37feb
moved one test to SingleAccountOverloadsWithParametersMockedTest.java
fadidurah Mar 21, 2022
6b78030
Trigger Pipelines
fadidurah Mar 21, 2022
72194d5
change testSignInOnlyAllowedOnceWithParameters
fadidurah Mar 21, 2022
055bbe6
Trigger Pipelines
fadidurah Mar 21, 2022
949ead2
do nothing in testSignInOnlyAllowedOnceWithParameters
fadidurah Mar 21, 2022
407aa23
trying without new devicecode test
fadidurah Mar 21, 2022
80c89ed
Trigger Pipelines
fadidurah Mar 21, 2022
17b1743
Trigger Pipelines
fadidurah Mar 21, 2022
23939bf
Trigger Pipelines
fadidurah Mar 21, 2022
be25b76
Added countdownLatch
fadidurah Mar 21, 2022
9971395
Trigger Pipelines
fadidurah Mar 21, 2022
5def901
Trigger Pipelines
fadidurah Mar 21, 2022
a1d360e
Trigger Pipelines
fadidurah Mar 22, 2022
d2c0ed1
Add back device code test
fadidurah Mar 22, 2022
0199f36
Trigger Pipelines
fadidurah Mar 22, 2022
e0b9e71
Trigger Pipelines
fadidurah Mar 22, 2022
b586176
Trigger Pipelines
fadidurah Mar 22, 2022
7f1767a
Trigger Pipelines
fadidurah Mar 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions msal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ dependencies {
implementation "cz.msebera.android:httpclient:$rootProject.ext.mseberaApacheHttpClientVersion"
implementation "androidx.constraintlayout:constraintlayout:$rootProject.ext.constraintLayoutVersion"

compileOnly "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
annotationProcessor "org.projectlombok:lombok:$rootProject.ext.lombokVersion"

// test dependencies
testImplementation "junit:junit:$rootProject.ext.junitVersion"
//mockito-inline was introduced in mockito 2.7.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,10 @@
public interface IPublicClientApplication {

/**
* Acquire token interactively, will pop-up webUI. Interactive flow will skip the cache lookup.
* Default value for {@link Prompt} is {@link Prompt#SELECT_ACCOUNT}.
*
* @param activity Non-null {@link Activity} that is used as the parent activity for launching the {@link com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity}.
* @param scopes The non-null array of scopes to be requested for the access token.
* MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
* @param callback The {@link AuthenticationCallback} to receive the result back.
* 1) If user cancels the flow by pressing the device back button, the result will be sent
* back via {@link AuthenticationCallback#onCancel()}.
* 2) If the sdk successfully receives the token back, result will be sent back via
* {@link AuthenticationCallback#onSuccess(IAuthenticationResult)}
* 3) All the other errors will be sent back via
* {@link AuthenticationCallback#onError(MsalException)}.
* @deprecated This method is now deprecated. The library is moving towards standardizing the use of TokenParameter subclasses as the
* parameters for the API. Use {@link IPublicClientApplication#acquireToken(AcquireTokenParameters)} instead.
*/
@Deprecated
void acquireToken(@NonNull final Activity activity,
@NonNull final String[] scopes,
@NonNull final AuthenticationCallback callback
Expand Down Expand Up @@ -92,6 +82,16 @@ void acquireToken(@NonNull final Activity activity,
* @param scopes the desired access scopes
* @param callback callback object used to communicate with the API throughout the protocol
*/
void acquireTokenWithDeviceCode(@NonNull List<String> scopes, @NonNull final DeviceCodeFlowCallback callback);

/**
* @deprecated This method is now deprecated. The library is moving away from using an array for scopes.
* Use {@link IPublicClientApplication#acquireTokenWithDeviceCode(List, DeviceCodeFlowCallback)} instead.
*
* @param scopes the desired access scopes
* @param callback callback object used to communicate with the API throughout the protocol
*/
@Deprecated
void acquireTokenWithDeviceCode(@NonNull String[] scopes, @NonNull final DeviceCodeFlowCallback callback);

/**
Expand Down Expand Up @@ -235,7 +235,7 @@ interface IMultipleAccountApplicationCreatedListener {
* 3). Receiving an exception detailing what went wrong in the protocol
* via {@link DeviceCodeFlowCallback#onError(MsalException)}.
* <p>
* Refer to {@link PublicClientApplication#acquireTokenWithDeviceCode(String[], DeviceCodeFlowCallback)}.
* Refer to {@link PublicClientApplication#acquireTokenWithDeviceCode(List, DeviceCodeFlowCallback)}.
*/
interface DeviceCodeFlowCallback {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,50 +66,32 @@ public interface ISingleAccountPublicClientApplication extends IPublicClientAppl
* Allows a user to sign in to your application with one of their accounts. This method may only
* be called once: once a user is signed in, they must first be signed out before another user
* may sign in. If you wish to prompt the existing user for credentials use
* {@link #signInAgain(Activity, String[], Prompt, AuthenticationCallback)} or
* {@link #signInAgain(SignInParameters)} or
* {@link #acquireToken(AcquireTokenParameters)}.
* <p>
* Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common
* or the default authority specified by you in your configuration
* or the default authority specified by you in your configuration.
*
* @param activity Non-null {@link Activity} that is used as the parent activity for launching the {@link com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity}.
* @param loginHint Optional. If provided, will be used as the query parameter sent for authenticating the user,
* which will have the UPN pre-populated.
* @param scopes The non-null array of scopes to be consented to during sign in.
* MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
* The access token returned is for MS Graph and will allow you to query for additional information about the signed in account.
* @param callback {@link AuthenticationCallback} that is used to send the result back. The success result will be
* sent back via {@link AuthenticationCallback#onSuccess(IAuthenticationResult)}.
* Failure case will be sent back via {
* @link AuthenticationCallback#onError(MsalException)}.
* @param signInParameters the {@link SignInParameters} containing the needed fields for signIn flow.
*/
void signIn(@NonNull final SignInParameters signInParameters);

/**
* @deprecated This method is now deprecated. The library is moving towards standardizing the use of TokenParameter subclasses as the
* parameters for the API. Use {@link ISingleAccountPublicClientApplication#signIn(SignInParameters)} instead.
*/
@Deprecated
void signIn(@NonNull final Activity activity,
@Nullable final String loginHint,
@NonNull final String[] scopes,
@NonNull final AuthenticationCallback callback
);

/**
* Allows a user to sign in to your application with one of their accounts. This method may only
* be called once: once a user is signed in, they must first be signed out before another user
* may sign in. If you wish to prompt the existing user for credentials use
* {@link #signInAgain(Activity, String[], Prompt, AuthenticationCallback)} or
* {@link #acquireToken(AcquireTokenParameters)}.
* <p>
* Note: The authority used to make the sign in request will be either the MSAL default: https://login.microsoftonline.com/common
* or the default authority specified by you in your configuration
*
* @param activity Non-null {@link Activity} that is used as the parent activity for launching the {@link com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity}.
* @param loginHint Optional. If provided, will be used as the query parameter sent for authenticating the user,
* which will have the UPN pre-populated.
* @param scopes The non-null array of scopes to be consented to during sign in.
* MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
* The access token returned is for MS Graph and will allow you to query for additional information about the signed in account.
* @param callback {@link AuthenticationCallback} that is used to send the result back. The success result will be
* sent back via {@link AuthenticationCallback#onSuccess(IAuthenticationResult)}.
* Failure case will be sent back via {
* @link AuthenticationCallback#onError(MsalException)}.
* @deprecated This method is now deprecated. The library is moving towards standardizing the use of TokenParameter subclasses as the
* parameters for the API. Use {@link ISingleAccountPublicClientApplication#signIn(SignInParameters)} instead.
*/
@Deprecated
void signIn(@NonNull final Activity activity,
@Nullable final String loginHint,
@NonNull final String[] scopes,
Expand All @@ -122,22 +104,17 @@ void signIn(@NonNull final Activity activity,
* <p>
* Note: The authority used to make the sign in request will be either the MSAL default:
* https://login.microsoftonline.com/common or the default authority specified by you in your
* configuration.
* configuration. This flow requires activity, scopes, and callback. Prompt is optional.
*
* @param activity Non-null {@link Activity} that is used as the parent activity for
* launching the {@link com.microsoft.identity.common.internal.providers.oauth2.AuthorizationActivity}.
* @param scopes The non-null array of scopes to be consented to during sign in.
* MSAL always sends the scopes 'openid profile offline_access'. Do
* not include any of these scopes in the scope parameter. The access
* token returned is for MS Graph and will allow you to query for
* additional information about the signed in account.
* @param prompt Nullable. Indicates the type of user interaction that is required.
* If no argument is supplied the default behavior will be used.
* @param callback {@link AuthenticationCallback} that is used to send the result back.
* The success result will be sent back via
* {@link AuthenticationCallback#onSuccess(IAuthenticationResult)}.
* Failure case will be sent back via {@link AuthenticationCallback#onError(MsalException)}.
* @param signInParameters the {@link SignInParameters} containing the needed fields for signIn flow.
*/
void signInAgain(@NonNull final SignInParameters signInParameters);

/**
* @deprecated This method is now deprecated. The library is moving towards standardizing the use of TokenParameter subclasses as the
* parameters for the API. Use {@link ISingleAccountPublicClientApplication#signInAgain(SignInParameters)} instead.
*/
@Deprecated
void signInAgain(@NonNull final Activity activity,
@NonNull final String[] scopes,
@Nullable final Prompt prompt,
Expand Down Expand Up @@ -166,14 +143,15 @@ void signInAgain(@NonNull final Activity activity,
* no valid access token exists, the sdk will try to find a refresh token and use the refresh token to get a new access token. If refresh token does not exist
* or it fails the refresh, exception will be sent back via callback.
*
* @param scopes The non-null array of scopes to be requested for the access token.
* MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
* @param authority Authority to issue the token.
* @param callback {@link SilentAuthenticationCallback} that is used to send the result back. The success result will be
* sent back via {@link SilentAuthenticationCallback#onSuccess(IAuthenticationResult)}.
* Failure case will be sent back via {
* @link AuthenticationCallback#onError(MsalException)}.
* @param acquireTokenSilentParameters the {@link AcquireTokenSilentParameters} containing the needed fields for acquireTokenSilent flow.
*/
void acquireTokenSilentAsync(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters);

/**
* @deprecated This method is now deprecated. The library is moving towards standardizing the use of TokenParameter subclasses as the
* parameters for the API. Use {@link ISingleAccountPublicClientApplication#acquireTokenSilentAsync(AcquireTokenSilentParameters)} instead.
*/
@Deprecated
void acquireTokenSilentAsync(@NonNull final String[] scopes,
@NonNull final String authority,
@NonNull final SilentAuthenticationCallback callback
Expand All @@ -184,11 +162,17 @@ void acquireTokenSilentAsync(@NonNull final String[] scopes,
* no valid access token exists, the sdk will try to find a refresh token and use the refresh token to get a new access token. If refresh token does not exist
* or it fails the refresh, exception will be sent back via callback.
*
* @param scopes The non-null array of scopes to be requested for the access token.
* MSAL always sends the scopes 'openid profile offline_access'. Do not include any of these scopes in the scope parameter.
* @param authority Authority to issue the token.
* @param acquireTokenSilentParameters the {@link AcquireTokenSilentParameters} containing the needed parameters for acquireTokenSilent flow.
*/
@WorkerThread
IAuthenticationResult acquireTokenSilent(@NonNull final AcquireTokenSilentParameters acquireTokenSilentParameters) throws InterruptedException, MsalException;

/**
* @deprecated This method is now deprecated. The library is moving towards standardizing the use of TokenParameter subclasses as the
* parameters for the API. Use {@link ISingleAccountPublicClientApplication#acquireTokenSilent(AcquireTokenSilentParameters)} instead.
*/
@WorkerThread
@Deprecated
IAuthenticationResult acquireTokenSilent(@NonNull final String[] scopes,
@NonNull final String authority) throws MsalException, InterruptedException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.microsoft.identity.common.java.util.ResultFuture;
import com.microsoft.identity.common.logging.Logger;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;

Expand All @@ -65,11 +66,17 @@ protected MultipleAccountPublicClientApplication(@NonNull PublicClientApplicatio
super(config);
}

//TODO: Add acquireTokenSilent(AcquireTokenSilentParameters)

//TODO: Deprecate
@Override
public IAuthenticationResult acquireTokenSilent(@NonNull String[] scopes, @NonNull IAccount account, @NonNull String authority) throws MsalException, InterruptedException {
return acquireTokenSilentSyncInternal(scopes, authority, account, false, PublicApiId.MULTIPLE_ACCOUNT_PCA_ACQUIRE_TOKEN_SILENT_WITH_SCOPES_ACCOUNT_AUTHORITY);
}

//TODO: Add acquireTokenSilentAsync(AcquireTokenSilentParameters)

//TODO: Deprecate
@Override
public void acquireTokenSilentAsync(@NonNull final String[] scopes,
@NonNull final IAccount account,
Expand Down Expand Up @@ -431,6 +438,9 @@ public void onError(@NonNull MsalException exception) {
}
}

//TODO: Add acquireToken(AcquireTokenParameters)

//TODO: Deprecate
@Override
public void acquireToken(@NonNull final Activity activity,
@NonNull final String[] scopes,
Expand All @@ -439,7 +449,7 @@ public void acquireToken(@NonNull final Activity activity,
final AcquireTokenParameters acquireTokenParameters = buildAcquireTokenParameters(
activity,
null,
scopes,
Arrays.asList(scopes),
null, // account
null, // uiBehavior
null, // extraQueryParams
Expand Down
Loading