Search in sources :

Example 1 with DeviceCodeAccount

use of com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount in project azure-tools-for-java by Microsoft.

the class SignInCommandHandler method loginDeviceCodeSingle.

private static Single<DeviceCodeAccount> loginDeviceCodeSingle() {
    final AzureString title = AzureOperationBundle.title("account.sign_in");
    final AzureTask<DeviceCodeAccount> deviceCodeTask = new AzureTask<>(null, title, true, () -> {
        final AzureAccount az = Azure.az(AzureAccount.class);
        return (DeviceCodeAccount) checkCanceled(null, az.loginAsync(AuthType.DEVICE_CODE, true), () -> {
            throw Lombok.sneakyThrow(new InterruptedException("user cancel"));
        });
    });
    return AzureTaskManager.getInstance().runInBackgroundAsObservable(deviceCodeTask).toSingle();
}
Also used : DeviceCodeAccount(com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 2 with DeviceCodeAccount

use of com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount in project azure-tools-for-java by Microsoft.

the class AzureSignInAction method loginDeviceCodeSingle.

private static Single<DeviceCodeAccount> loginDeviceCodeSingle() {
    final AzureString title = AzureOperationBundle.title("account.sign_in");
    final AzureTask<DeviceCodeAccount> deviceCodeTask = new AzureTask<>(null, title, true, () -> {
        final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
        indicator.setIndeterminate(true);
        final AzureAccount az = Azure.az(AzureAccount.class);
        return (DeviceCodeAccount) checkCanceled(indicator, az.loginAsync(AuthType.DEVICE_CODE, true), () -> {
            throw Lombok.sneakyThrow(new InterruptedException("user cancel"));
        });
    });
    return AzureTaskManager.getInstance().runInBackgroundAsObservable(deviceCodeTask).toSingle();
}
Also used : DeviceCodeAccount(com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Aggregations

AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)2 DeviceCodeAccount (com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1