Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Eastman <[email protected]>
  • Loading branch information
baywet and andrueastman authored Dec 1, 2022
1 parent add6960 commit 58a82e8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Kiota.Builder.SearchProviders.GitHub.Authentication;
public class PatAuthenticationProvider : BaseAuthenticationProvider<PatAccessTokenProvider>
{
public PatAuthenticationProvider(string clientId, string scope, IEnumerable<string> validHosts, ILogger logger, ITokenStorageService StorageService) :
base(clientId, scope, validHosts, logger, (clientId, scope, validHosts) => new PatAccessTokenProvider {
base(clientId, scope, validHosts, logger, (_, _, validHosts) => new PatAccessTokenProvider {
StorageService = StorageService,
AllowedHostsValidator = new (validHosts),
}, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task<bool> IsTokenPresentAsync(CancellationToken cancellationToken)
if (!File.Exists(target))
return false;
var fileDate = File.GetLastWriteTime(target);
if(fileDate > DateTime.Now.AddMonths(6)) {
if(fileDate > DateTime.Now.AddMonths(-6)) {
await DeleteTokenAsync(cancellationToken);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ private Uri GetAuthorizeUrl(Guid state) {
tokenRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
using var tokenResponse = await HttpClient.SendAsync(tokenRequest, cancellationToken);
tokenResponse.EnsureSuccessStatusCode();
var tokenContent = await tokenResponse.Content.ReadAsStringAsync(cancellationToken);
var result = JsonSerializer.Deserialize<AccessCodeResponse>(tokenContent);
var result = await tokenResponse.Content.ReadFromJsonAsync<AccessCodeResponse>(cancellationToken:cancellationToken);
if ("authorization_pending".Equals(result?.Error, StringComparison.OrdinalIgnoreCase))
return null;
else if (!string.IsNullOrEmpty(result?.Error))
Expand Down
2 changes: 1 addition & 1 deletion src/kiota/Handlers/BaseKiotaCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private IAuthenticationProvider GetGitHubPatAuthenticationProvider(ILogger logge
new List<string> { Configuration.Search.GitHub.ApiBaseUrl.Host },
logger,
GetGitHubPatStorageService(logger));
protected async Task<KiotaSearcher> GetKiotaSearcher(ILoggerFactory loggerFactory, CancellationToken cancellationToken) {
protected async Task<KiotaSearcher> GetKiotaSearcherAsync(ILoggerFactory loggerFactory, CancellationToken cancellationToken) {
var logger = loggerFactory.CreateLogger<KiotaSearcher>();
var deviceCodeSignInCallback = GetIsGitHubDeviceSignedInCallback(logger);
var patSignInCallBack = GetIsGitHubPatSignedInCallback(logger);
Expand Down

0 comments on commit 58a82e8

Please sign in to comment.