Skip to content
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

Removed teams app check for DCF #2153

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2111,39 +2111,32 @@ public void acquireTokenWithDeviceCode(@NonNull List<String> scopes,
try (final Scope scope = SpanExtension.makeCurrentSpan(span)) {
span.setAttribute(AttributeName.application_name.name(), mPublicClientConfiguration.getAppContext().getPackageName());

// Currently this method is only supported for Teams app
if (!packageHelper.verifyIfValidTeamsPackage(context.getPackageName())) {
span.setAttribute(AttributeName.error_message.name(), "acquireTokenWithDeviceCode with claims is not supported for current package.");
throw new UnsupportedOperationException(ERR_UNSUPPORTED_OPERATION);
} else {
DeviceCodeFlowParameters.Builder builder = new DeviceCodeFlowParameters.Builder();

if (null != correlationId) {
builder.withCorrelationId(correlationId);
span.setAttribute(AttributeName.correlation_id.name(), correlationId.toString());
}
DeviceCodeFlowParameters.Builder builder = new DeviceCodeFlowParameters.Builder();

DeviceCodeFlowParameters deviceCodeFlowParameters =
builder.withScopes(scopes)
.withClaims(claimsRequest)
.build();

final DeviceCodeFlowCommandParameters commandParameters = CommandParametersAdapter
.createDeviceCodeFlowWithClaimsCommandParameters(
mPublicClientConfiguration,
mPublicClientConfiguration.getOAuth2TokenCache(),
deviceCodeFlowParameters);

final DeviceCodeFlowCommandCallback deviceCodeFlowCommandCallback = getDeviceCodeFlowCommandCallback(callback);
final DeviceCodeFlowCommand deviceCodeFlowCommand = new DeviceCodeFlowCommand(
commandParameters,
new MSALControllerFactory(mPublicClientConfiguration),
deviceCodeFlowCommandCallback,
PublicApiId.DEVICE_CODE_FLOW_WITH_CLAIMS_AND_CALLBACK
);

CommandDispatcher.submitSilent(deviceCodeFlowCommand);
if (null != correlationId) {
builder.withCorrelationId(correlationId);
span.setAttribute(AttributeName.correlation_id.name(), correlationId.toString());
}

DeviceCodeFlowParameters deviceCodeFlowParameters =
builder.withScopes(scopes)
.withClaims(claimsRequest)
.build();

final DeviceCodeFlowCommandParameters commandParameters = CommandParametersAdapter
.createDeviceCodeFlowWithClaimsCommandParameters(
mPublicClientConfiguration,
mPublicClientConfiguration.getOAuth2TokenCache(),
deviceCodeFlowParameters);

final DeviceCodeFlowCommandCallback deviceCodeFlowCommandCallback = getDeviceCodeFlowCommandCallback(callback);
final DeviceCodeFlowCommand deviceCodeFlowCommand = new DeviceCodeFlowCommand(
commandParameters,
new MSALControllerFactory(mPublicClientConfiguration),
deviceCodeFlowCommandCallback,
PublicApiId.DEVICE_CODE_FLOW_WITH_CLAIMS_AND_CALLBACK
);
CommandDispatcher.submitSilent(deviceCodeFlowCommand);
span.setStatus(StatusCode.OK);
} catch (final Throwable throwable) {
span.setStatus(StatusCode.ERROR);
Expand Down
Loading