Skip to content

Commit

Permalink
samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Aldrich committed Dec 4, 2024
1 parent 87e8db9 commit 0e4c5b3
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Org.OpenAPITools.Client.Auth
/// </summary>
public class OAuthAuthenticator : IAuthenticator
{
private TokenResponse? _token;
private TokenResponse _token;

public string? Token
public string Token
{
get
{
Expand Down Expand Up @@ -98,8 +98,7 @@ protected async ValueTask<Parameter> GetAuthenticationParameter()
/// <returns>An authentication token.</returns>
async Task<string> GetToken()
{
var client = new RestClient(_tokenUrl,
configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));
var client = new RestClient(_tokenUrl, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));

var request = new RestRequest();
if (!string.IsNullOrWhiteSpace(_token?.RefreshToken))
Expand Down Expand Up @@ -132,6 +131,6 @@ async Task<string> GetToken()
}

public async ValueTask Authenticate(IRestClient client, RestRequest request)
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TokenResponse
public DateTime Created { get; set; }

[JsonProperty("refresh_token")]
public string? RefreshToken { get; set; }
public string RefreshToken { get; set; }

public DateTime? ExpiresAt => ExpiresIn == null ? null : Created.AddSeconds(ExpiresIn.Value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Org.OpenAPITools.Client.Auth
/// </summary>
public class OAuthAuthenticator : IAuthenticator
{
private TokenResponse? _token;
private TokenResponse _token;

public string? Token
public string Token
{
get
{
Expand Down Expand Up @@ -98,8 +98,7 @@ protected async ValueTask<Parameter> GetAuthenticationParameter()
/// <returns>An authentication token.</returns>
async Task<string> GetToken()
{
var client = new RestClient(_tokenUrl,
configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));
var client = new RestClient(_tokenUrl, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));

var request = new RestRequest();
if (!string.IsNullOrWhiteSpace(_token?.RefreshToken))
Expand Down Expand Up @@ -132,6 +131,6 @@ async Task<string> GetToken()
}

public async ValueTask Authenticate(IRestClient client, RestRequest request)
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TokenResponse
public DateTime Created { get; set; }

[JsonProperty("refresh_token")]
public string? RefreshToken { get; set; }
public string RefreshToken { get; set; }

public DateTime? ExpiresAt => ExpiresIn == null ? null : Created.AddSeconds(ExpiresIn.Value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Org.OpenAPITools.Client.Auth
/// </summary>
public class OAuthAuthenticator : IAuthenticator
{
private TokenResponse? _token;
private TokenResponse _token;

public string? Token
public string Token
{
get
{
Expand Down Expand Up @@ -98,8 +98,7 @@ protected async ValueTask<Parameter> GetAuthenticationParameter()
/// <returns>An authentication token.</returns>
async Task<string> GetToken()
{
var client = new RestClient(_tokenUrl,
configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));
var client = new RestClient(_tokenUrl, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));

var request = new RestRequest();
if (!string.IsNullOrWhiteSpace(_token?.RefreshToken))
Expand Down Expand Up @@ -132,6 +131,6 @@ async Task<string> GetToken()
}

public async ValueTask Authenticate(IRestClient client, RestRequest request)
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TokenResponse
public DateTime Created { get; set; }

[JsonProperty("refresh_token")]
public string? RefreshToken { get; set; }
public string RefreshToken { get; set; }

public DateTime? ExpiresAt => ExpiresIn == null ? null : Created.AddSeconds(ExpiresIn.Value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ protected async ValueTask<Parameter> GetAuthenticationParameter()
/// <returns>An authentication token.</returns>
async Task<string> GetToken()
{
var client = new RestClient(_tokenUrl,
configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));
var client = new RestClient(_tokenUrl, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));

var request = new RestRequest();
if (!string.IsNullOrWhiteSpace(_token?.RefreshToken))
Expand Down Expand Up @@ -132,6 +131,6 @@ async Task<string> GetToken()
}

public async ValueTask Authenticate(IRestClient client, RestRequest request)
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ protected async ValueTask<Parameter> GetAuthenticationParameter()
/// <returns>An authentication token.</returns>
async Task<string> GetToken()
{
var client = new RestClient(_tokenUrl,
configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));
var client = new RestClient(_tokenUrl, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));

var request = new RestRequest();
if (!string.IsNullOrWhiteSpace(_token?.RefreshToken))
Expand Down Expand Up @@ -132,6 +131,6 @@ async Task<string> GetToken()
}

public async ValueTask Authenticate(IRestClient client, RestRequest request)
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Org.OpenAPITools.Client.Auth
/// </summary>
public class OAuthAuthenticator : IAuthenticator
{
private TokenResponse? _token;
private TokenResponse _token;

public string? Token
public string Token
{
get
{
Expand Down Expand Up @@ -98,8 +98,7 @@ protected async ValueTask<Parameter> GetAuthenticationParameter()
/// <returns>An authentication token.</returns>
async Task<string> GetToken()
{
var client = new RestClient(_tokenUrl,
configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));
var client = new RestClient(_tokenUrl, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));

var request = new RestRequest();
if (!string.IsNullOrWhiteSpace(_token?.RefreshToken))
Expand Down Expand Up @@ -132,6 +131,6 @@ async Task<string> GetToken()
}

public async ValueTask Authenticate(IRestClient client, RestRequest request)
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TokenResponse
public DateTime Created { get; set; }

[JsonProperty("refresh_token")]
public string? RefreshToken { get; set; }
public string RefreshToken { get; set; }

public DateTime? ExpiresAt => ExpiresIn == null ? null : Created.AddSeconds(ExpiresIn.Value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Org.OpenAPITools.Client.Auth
/// </summary>
public class OAuthAuthenticator : IAuthenticator
{
private TokenResponse? _token;
private TokenResponse _token;

public string? Token
public string Token
{
get
{
Expand Down Expand Up @@ -98,8 +98,7 @@ protected async ValueTask<Parameter> GetAuthenticationParameter()
/// <returns>An authentication token.</returns>
async Task<string> GetToken()
{
var client = new RestClient(_tokenUrl,
configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));
var client = new RestClient(_tokenUrl, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(_serializerSettings, _configuration)));

var request = new RestRequest();
if (!string.IsNullOrWhiteSpace(_token?.RefreshToken))
Expand Down Expand Up @@ -132,6 +131,6 @@ async Task<string> GetToken()
}

public async ValueTask Authenticate(IRestClient client, RestRequest request)
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
=> request.AddOrUpdateParameter(await GetAuthenticationParameter().ConfigureAwait(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TokenResponse
public DateTime Created { get; set; }

[JsonProperty("refresh_token")]
public string? RefreshToken { get; set; }
public string RefreshToken { get; set; }

public DateTime? ExpiresAt => ExpiresIn == null ? null : Created.AddSeconds(ExpiresIn.Value);
}
Expand Down

0 comments on commit 0e4c5b3

Please sign in to comment.