Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -18,11 +18,11 @@ public class AdalDaemonAuthenticationProvider : AdalAuthenticationProviderBase
{
private const int _retryCount = 3;
private const int _retrySleepDuration = 3000;
string _clientId;
string _clientKey;
protected string _clientId;
protected string _clientKey;

public IAuthenticationContextWrapper authContextWrapper;
ClientCredential clientCredential;
protected ClientCredential clientCredential;

protected override AuthenticateUserDelegate AuthenticateUser { get; set; }
protected override AuthenticateUserSilentlyDelegate AuthenticateUserSilently { get; set; }
Expand All @@ -44,8 +44,8 @@ public AdalDaemonAuthenticationProvider(
_clientKey = clientSecret;

string authority = String.Format(CultureInfo.InvariantCulture, "https://login.microsoftonline.com/{0}", tenant);
authContextWrapper = authenticationContextWrapper;
clientCredential = new ClientCredential(_clientId, _clientKey);
this.authContextWrapper = authenticationContextWrapper;
this.clientCredential = new ClientCredential(_clientId, _clientKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.clientCredential = new ClientCredential(this._clientId, this._clientKey);

Please look for this everywhere in the file. Instance members and methods should always have this.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 1 extra line

this.AuthenticateUser = this.PromptUserForAuthenticationAsync;
this.AuthenticateUserSilently = this.SilentlyAuthenticateUserAsync;
Expand All @@ -63,7 +63,7 @@ public async Task AuthenticateUserAsync(string serviceResourceId)
retry = false;
try
{
result = await this.authContextWrapper.AcquireDaemonTokenSilentAsync(
result = await this.authContextWrapper.AcquireTokenSilentAsync(
serviceResourceId,
clientCredential);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ private async Task<IAuthenticationResult> SilentlyAuthenticateUserAsync(
string userId,
bool throwOnError)
{
var result = await this.authContextWrapper.AcquireDaemonTokenSilentAsync(
var result = await this.authContextWrapper.AcquireTokenSilentAsync(
serviceResourceId,
clientCredential);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ITokenCache TokenCache
/// <param name="resource">The resource to authenticate against.</param>
/// <param name="clientCredential">The client credential of the application.</param>
/// <returns>The <see cref="IAuthenticationResult"/>.</returns>
public async Task<IAuthenticationResult> AcquireDaemonTokenSilentAsync(string resource, ClientCredential clientCredential)
public async Task<IAuthenticationResult> AcquireTokenSilentAsync(string resource, ClientCredential clientCredential)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes sorry, this should actually be AcquireTokenAsync. It should match the call to AuthenticationContext to make it a little easier for the client to figure out what's happening under the covers. Sorry if I gave you the wrong name before :(

{
var result = await this.authenticationContext.AcquireTokenAsync(resource, clientCredential).ConfigureAwait(false);
return result == null ? null : new AuthenticationResultWrapper(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IAuthenticationContextWrapper
/// <param name="resource">The resource to authenticate against.</param>
/// <param name="clientCredential">The client credential of the application.</param>
/// <returns>The <see cref="IAuthenticationResult"/>.</returns>
Task<IAuthenticationResult> AcquireDaemonTokenSilentAsync(string resource, ClientCredential clientCredential);
Task<IAuthenticationResult> AcquireTokenSilentAsync(string resource, ClientCredential clientCredential);

/// <summary>
/// Authenticates the user silently using <see cref="AuthenticationContext.AcquireTokenSilentAsync(string, string, UserIdentifier)"/>.
Expand Down