Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Addressing device code flow issue and performing minor code cleanup (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaiah Williams authored Nov 11, 2019
1 parent e11c8ac commit 6c694a6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

* Authentication
* Addressed issue preventing the [Test-PartnerSecurityRequirement](https://docs.microsoft.com/powershell/module/partnercenter/test-partnersecurityrequirement) command from working as expected
* Addressed issue [#186](https://github.com/microsoft/Partner-Center-PowerShell/issues/186) that was preventing access token from being generated when using the device code flow

## 2.0.1911.2

Expand Down
11 changes: 2 additions & 9 deletions src/PowerShell/Authenticators/DeviceCodeAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Microsoft.Store.PartnerCenter.PowerShell.Authenticators
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Extensions;
Expand All @@ -28,17 +27,11 @@ public override Task<AuthenticationResult> AuthenticateAsync(AuthenticationParam
{
IPublicClientApplication app = GetClient(parameters.Account, parameters.Environment).AsPublicClient();

return GetResponseAsync(app, parameters.Scopes, promptAction, cancellationToken);
}

private async Task<AuthenticationResult> GetResponseAsync(IPublicClientApplication app, IEnumerable<string> scopes, Action<string> promptAction = null, CancellationToken cancellationToken = default)
{
return await app.AcquireTokenWithDeviceCode(scopes, deviceCodeResult =>
return app.AcquireTokenWithDeviceCode(parameters.Scopes, deviceCodeResult =>
{
promptAction(deviceCodeResult.Message);
Console.WriteLine(deviceCodeResult.Message);
return Task.CompletedTask;
}).ExecuteAsync(cancellationToken);

}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/PowerShell/Commands/GetPartnerUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace Microsoft.Store.PartnerCenter.PowerShell.Commands
{
using System.Management.Automation;
using Models.Authentication;
using Models;
using Models.Authentication;

[Cmdlet(VerbsCommon.Get, "PartnerUser"), OutputType(typeof(Microsoftgraphuser))]
public class GetPartnerUser : PartnerCmdlet
Expand Down
2 changes: 1 addition & 1 deletion src/PowerShell/Commands/TestPartnerSecurityRequirement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected override void ProcessRecord()
environment,
new[] { $"{environment.PartnerCenterEndpoint}/user_impersonation" },
Message,
WriteWarning,
WriteWarning,
CancellationToken);


Expand Down

0 comments on commit 6c694a6

Please sign in to comment.