Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
78b3f7b
feat: add scope for oauth2
mjansrud Jul 16, 2024
e64153b
fix: add parameter AlwaysMultipartFormData
mjansrud Jul 16, 2024
a9c2fe9
fix: string to boolean
mjansrud Jul 16, 2024
c2eab56
fix: optional bool
mjansrud Jul 16, 2024
babbf90
fix: null checks
mjansrud Jul 16, 2024
a127646
Optional string
mjansrud Jul 16, 2024
bcc94f9
Remove all references to OAuthMultipartFormData
mjansrud Jul 16, 2024
3fc87ce
Remove _multipartFormData = multipartFormData;
mjansrud Jul 16, 2024
312742c
Remove typo
mjansrud Jul 16, 2024
f051f26
Run generate-samples and export_docs_generators
mjansrud Jul 16, 2024
778b423
Revert "Run generate-samples and export_docs_generators"
mjansrud Jul 16, 2024
4b2c3e8
Merge branch 'master' of github.com:OpenAPITools/openapi-generator in…
mjansrud Jul 16, 2024
cc124f6
Switch to string.IsNullOrEmpty, add langVersion 8
mjansrud Jul 16, 2024
18dc2a1
Add langVersion 8 in ConditionalSerialization
mjansrud Jul 16, 2024
df907f9
Use regular strings for netstandard2.0
mjansrud Jul 17, 2024
87f198c
Remove references to langVersion 8
mjansrud Jul 17, 2024
d215eba
Fix variable
mjansrud Jul 17, 2024
3350936
Use template engine to toggle nullable string
mjansrud Jul 17, 2024
e16d0e2
Merge branch 'master' of github.com:OpenAPITools/openapi-generator in…
mjansrud Jul 17, 2024
944ca2f
Trigger tests
mjansrud Jul 17, 2024
532efb4
Generate samples
mjansrud Jul 17, 2024
c52d1aa
Trigger build
mjansrud Jul 17, 2024
90c15a7
Use {{nrt?}}
mjansrud Jul 19, 2024
00746a0
Merge branch 'csharp-oauth-scope' of https://github.com/snokam/openap…
wing328 Jul 24, 2024
f534628
update samples
wing328 Jul 24, 2024
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 @@ -474,6 +474,7 @@ namespace {{packageName}}.Client
configuration.OAuthTokenUrl,
configuration.OAuthClientId,
configuration.OAuthClientSecret,
configuration.OAuthScope,
configuration.OAuthFlow,
SerializerSettings,
configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ namespace {{packageName}}.Client
/// <value>The OAuth Client Secret.</value>
public virtual string OAuthClientSecret { get; set; }

/// <summary>
/// Gets or sets the client scope for OAuth2 authentication.
/// </summary>
/// <value>The OAuth Client Scope.</value>
public virtual string{{nrt?}} OAuthScope { get; set; }

/// <summary>
/// Gets or sets the flow for OAuth2 authentication.
/// </summary>
Expand Down Expand Up @@ -711,6 +717,7 @@ namespace {{packageName}}.Client
OAuthTokenUrl = second.OAuthTokenUrl ?? first.OAuthTokenUrl,
OAuthClientId = second.OAuthClientId ?? first.OAuthClientId,
OAuthClientSecret = second.OAuthClientSecret ?? first.OAuthClientSecret,
OAuthScope = second.OAuthScope ?? first.OAuthScope,
OAuthFlow = second.OAuthFlow ?? first.OAuthFlow,
{{/hasOAuthMethods}}
{{/useRestSharp}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ namespace {{packageName}}.Client
/// <value>OAuth Client Secret.</value>
string OAuthClientSecret { get; }

/// <summary>
/// Gets the OAuth token scope.
/// </summary>
/// <value>OAuth Token scope.</value>
string{{nrt?}} OAuthScope { get; }

/// <summary>
/// Gets the OAuth flow.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace {{packageName}}.Client.Auth
readonly string _tokenUrl;
readonly string _clientId;
readonly string _clientSecret;
readonly string{{nrt?}} _scope;
readonly string _grantType;
readonly JsonSerializerSettings _serializerSettings;
readonly IReadableConfiguration _configuration;
Expand All @@ -27,13 +28,15 @@ namespace {{packageName}}.Client.Auth
string tokenUrl,
string clientId,
string clientSecret,
string{{nrt?}} scope,
OAuthFlow? flow,
JsonSerializerSettings serializerSettings,
IReadableConfiguration configuration) : base("")
{
_tokenUrl = tokenUrl;
_clientId = clientId;
_clientSecret = clientSecret;
_scope = scope;
_serializerSettings = serializerSettings;
_configuration = configuration;

Expand Down Expand Up @@ -80,6 +83,12 @@ namespace {{packageName}}.Client.Auth
.AddParameter("grant_type", _grantType)
.AddParameter("client_id", _clientId)
.AddParameter("client_secret", _clientSecret);

if (!string.IsNullOrEmpty(_scope))
{
request.AddParameter("scope", _scope);
}

var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);

// RFC6749 - token_type is case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getRespon
configuration.OAuthTokenUrl,
configuration.OAuthClientId,
configuration.OAuthClientSecret,
configuration.OAuthScope,
configuration.OAuthFlow,
SerializerSettings,
configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class OAuthAuthenticator : AuthenticatorBase
readonly string _tokenUrl;
readonly string _clientId;
readonly string _clientSecret;
readonly string _scope;
readonly string _grantType;
readonly JsonSerializerSettings _serializerSettings;
readonly IReadableConfiguration _configuration;
Expand All @@ -35,13 +36,15 @@ public OAuthAuthenticator(
string tokenUrl,
string clientId,
string clientSecret,
string scope,
OAuthFlow? flow,
JsonSerializerSettings serializerSettings,
IReadableConfiguration configuration) : base("")
{
_tokenUrl = tokenUrl;
_clientId = clientId;
_clientSecret = clientSecret;
_scope = scope;
_serializerSettings = serializerSettings;
_configuration = configuration;

Expand Down Expand Up @@ -88,6 +91,12 @@ async Task<string> GetToken()
.AddParameter("grant_type", _grantType)
.AddParameter("client_id", _clientId)
.AddParameter("client_secret", _clientSecret);

if (!string.IsNullOrEmpty(_scope))
{
request.AddParameter("scope", _scope);
}

var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);

// RFC6749 - token_type is case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ public string GetApiKeyWithPrefix(string apiKeyIdentifier)
/// <value>The OAuth Client Secret.</value>
public virtual string OAuthClientSecret { get; set; }

/// <summary>
/// Gets or sets the client scope for OAuth2 authentication.
/// </summary>
/// <value>The OAuth Client Scope.</value>
public virtual string OAuthScope { get; set; }

/// <summary>
/// Gets or sets the flow for OAuth2 authentication.
/// </summary>
Expand Down Expand Up @@ -622,6 +628,7 @@ public static IReadableConfiguration MergeConfigurations(IReadableConfiguration
OAuthTokenUrl = second.OAuthTokenUrl ?? first.OAuthTokenUrl,
OAuthClientId = second.OAuthClientId ?? first.OAuthClientId,
OAuthClientSecret = second.OAuthClientSecret ?? first.OAuthClientSecret,
OAuthScope = second.OAuthScope ?? first.OAuthScope,
OAuthFlow = second.OAuthFlow ?? first.OAuthFlow,
TempFolderPath = second.TempFolderPath ?? first.TempFolderPath,
DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public interface IReadableConfiguration
/// <value>OAuth Client Secret.</value>
string OAuthClientSecret { get; }

/// <summary>
/// Gets the OAuth token scope.
/// </summary>
/// <value>OAuth Token scope.</value>
string OAuthScope { get; }

/// <summary>
/// Gets the OAuth flow.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getRespon
configuration.OAuthTokenUrl,
configuration.OAuthClientId,
configuration.OAuthClientSecret,
configuration.OAuthScope,
configuration.OAuthFlow,
SerializerSettings,
configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class OAuthAuthenticator : AuthenticatorBase
readonly string _tokenUrl;
readonly string _clientId;
readonly string _clientSecret;
readonly string _scope;
readonly string _grantType;
readonly JsonSerializerSettings _serializerSettings;
readonly IReadableConfiguration _configuration;
Expand All @@ -35,13 +36,15 @@ public OAuthAuthenticator(
string tokenUrl,
string clientId,
string clientSecret,
string scope,
OAuthFlow? flow,
JsonSerializerSettings serializerSettings,
IReadableConfiguration configuration) : base("")
{
_tokenUrl = tokenUrl;
_clientId = clientId;
_clientSecret = clientSecret;
_scope = scope;
_serializerSettings = serializerSettings;
_configuration = configuration;

Expand Down Expand Up @@ -88,6 +91,12 @@ async Task<string> GetToken()
.AddParameter("grant_type", _grantType)
.AddParameter("client_id", _clientId)
.AddParameter("client_secret", _clientSecret);

if (!string.IsNullOrEmpty(_scope))
{
request.AddParameter("scope", _scope);
}

var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);

// RFC6749 - token_type is case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ public string GetApiKeyWithPrefix(string apiKeyIdentifier)
/// <value>The OAuth Client Secret.</value>
public virtual string OAuthClientSecret { get; set; }

/// <summary>
/// Gets or sets the client scope for OAuth2 authentication.
/// </summary>
/// <value>The OAuth Client Scope.</value>
public virtual string OAuthScope { get; set; }

/// <summary>
/// Gets or sets the flow for OAuth2 authentication.
/// </summary>
Expand Down Expand Up @@ -736,6 +742,7 @@ public static IReadableConfiguration MergeConfigurations(IReadableConfiguration
OAuthTokenUrl = second.OAuthTokenUrl ?? first.OAuthTokenUrl,
OAuthClientId = second.OAuthClientId ?? first.OAuthClientId,
OAuthClientSecret = second.OAuthClientSecret ?? first.OAuthClientSecret,
OAuthScope = second.OAuthScope ?? first.OAuthScope,
OAuthFlow = second.OAuthFlow ?? first.OAuthFlow,
HttpSigningConfiguration = second.HttpSigningConfiguration ?? first.HttpSigningConfiguration,
TempFolderPath = second.TempFolderPath ?? first.TempFolderPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public interface IReadableConfiguration
/// <value>OAuth Client Secret.</value>
string OAuthClientSecret { get; }

/// <summary>
/// Gets the OAuth token scope.
/// </summary>
/// <value>OAuth Token scope.</value>
string OAuthScope { get; }

/// <summary>
/// Gets the OAuth flow.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getRespon
configuration.OAuthTokenUrl,
configuration.OAuthClientId,
configuration.OAuthClientSecret,
configuration.OAuthScope,
configuration.OAuthFlow,
SerializerSettings,
configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class OAuthAuthenticator : AuthenticatorBase
readonly string _tokenUrl;
readonly string _clientId;
readonly string _clientSecret;
readonly string _scope;
readonly string _grantType;
readonly JsonSerializerSettings _serializerSettings;
readonly IReadableConfiguration _configuration;
Expand All @@ -35,13 +36,15 @@ public OAuthAuthenticator(
string tokenUrl,
string clientId,
string clientSecret,
string scope,
OAuthFlow? flow,
JsonSerializerSettings serializerSettings,
IReadableConfiguration configuration) : base("")
{
_tokenUrl = tokenUrl;
_clientId = clientId;
_clientSecret = clientSecret;
_scope = scope;
_serializerSettings = serializerSettings;
_configuration = configuration;

Expand Down Expand Up @@ -88,6 +91,12 @@ async Task<string> GetToken()
.AddParameter("grant_type", _grantType)
.AddParameter("client_id", _clientId)
.AddParameter("client_secret", _clientSecret);

if (!string.IsNullOrEmpty(_scope))
{
request.AddParameter("scope", _scope);
}

var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);

// RFC6749 - token_type is case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ public string GetApiKeyWithPrefix(string apiKeyIdentifier)
/// <value>The OAuth Client Secret.</value>
public virtual string OAuthClientSecret { get; set; }

/// <summary>
/// Gets or sets the client scope for OAuth2 authentication.
/// </summary>
/// <value>The OAuth Client Scope.</value>
public virtual string OAuthScope { get; set; }

/// <summary>
/// Gets or sets the flow for OAuth2 authentication.
/// </summary>
Expand Down Expand Up @@ -736,6 +742,7 @@ public static IReadableConfiguration MergeConfigurations(IReadableConfiguration
OAuthTokenUrl = second.OAuthTokenUrl ?? first.OAuthTokenUrl,
OAuthClientId = second.OAuthClientId ?? first.OAuthClientId,
OAuthClientSecret = second.OAuthClientSecret ?? first.OAuthClientSecret,
OAuthScope = second.OAuthScope ?? first.OAuthScope,
OAuthFlow = second.OAuthFlow ?? first.OAuthFlow,
HttpSigningConfiguration = second.HttpSigningConfiguration ?? first.HttpSigningConfiguration,
TempFolderPath = second.TempFolderPath ?? first.TempFolderPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public interface IReadableConfiguration
/// <value>OAuth Client Secret.</value>
string OAuthClientSecret { get; }

/// <summary>
/// Gets the OAuth token scope.
/// </summary>
/// <value>OAuth Token scope.</value>
string OAuthScope { get; }

/// <summary>
/// Gets the OAuth flow.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ private ApiResponse<T> ExecClient<T>(Func<RestClient, RestResponse<T>> getRespon
configuration.OAuthTokenUrl,
configuration.OAuthClientId,
configuration.OAuthClientSecret,
configuration.OAuthScope,
configuration.OAuthFlow,
SerializerSettings,
configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class OAuthAuthenticator : AuthenticatorBase
readonly string _tokenUrl;
readonly string _clientId;
readonly string _clientSecret;
readonly string? _scope;
readonly string _grantType;
readonly JsonSerializerSettings _serializerSettings;
readonly IReadableConfiguration _configuration;
Expand All @@ -35,13 +36,15 @@ public OAuthAuthenticator(
string tokenUrl,
string clientId,
string clientSecret,
string? scope,
OAuthFlow? flow,
JsonSerializerSettings serializerSettings,
IReadableConfiguration configuration) : base("")
{
_tokenUrl = tokenUrl;
_clientId = clientId;
_clientSecret = clientSecret;
_scope = scope;
_serializerSettings = serializerSettings;
_configuration = configuration;

Expand Down Expand Up @@ -88,6 +91,12 @@ async Task<string> GetToken()
.AddParameter("grant_type", _grantType)
.AddParameter("client_id", _clientId)
.AddParameter("client_secret", _clientSecret);

if (!string.IsNullOrEmpty(_scope))
{
request.AddParameter("scope", _scope);
}

var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);

// RFC6749 - token_type is case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ public string GetApiKeyWithPrefix(string apiKeyIdentifier)
/// <value>The OAuth Client Secret.</value>
public virtual string OAuthClientSecret { get; set; }

/// <summary>
/// Gets or sets the client scope for OAuth2 authentication.
/// </summary>
/// <value>The OAuth Client Scope.</value>
public virtual string? OAuthScope { get; set; }

/// <summary>
/// Gets or sets the flow for OAuth2 authentication.
/// </summary>
Expand Down Expand Up @@ -736,6 +742,7 @@ public static IReadableConfiguration MergeConfigurations(IReadableConfiguration
OAuthTokenUrl = second.OAuthTokenUrl ?? first.OAuthTokenUrl,
OAuthClientId = second.OAuthClientId ?? first.OAuthClientId,
OAuthClientSecret = second.OAuthClientSecret ?? first.OAuthClientSecret,
OAuthScope = second.OAuthScope ?? first.OAuthScope,
OAuthFlow = second.OAuthFlow ?? first.OAuthFlow,
HttpSigningConfiguration = second.HttpSigningConfiguration ?? first.HttpSigningConfiguration,
TempFolderPath = second.TempFolderPath ?? first.TempFolderPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public interface IReadableConfiguration
/// <value>OAuth Client Secret.</value>
string OAuthClientSecret { get; }

/// <summary>
/// Gets the OAuth token scope.
/// </summary>
/// <value>OAuth Token scope.</value>
string? OAuthScope { get; }

/// <summary>
/// Gets the OAuth flow.
/// </summary>
Expand Down
Loading