forked from loafle/openapi-generator-original
[csharp] fix authorization header casing issue (#16622)
* Capitalise auth scheme irrespective of token_type capitalisation * Changes from generate-samples.sh * Add comment to change
This commit is contained in:
parent
19d8dbc7d5
commit
f99002a974
@ -81,7 +81,17 @@ namespace {{packageName}}.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ namespace Org.OpenAPITools.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ namespace Org.OpenAPITools.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ namespace Org.OpenAPITools.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ namespace Org.OpenAPITools.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ namespace Org.OpenAPITools.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ namespace Org.OpenAPITools.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ namespace Org.OpenAPITools.Client.Auth
|
|||||||
.AddParameter("client_id", _clientId)
|
.AddParameter("client_id", _clientId)
|
||||||
.AddParameter("client_secret", _clientSecret);
|
.AddParameter("client_secret", _clientSecret);
|
||||||
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
var response = await client.PostAsync<TokenResponse>(request).ConfigureAwait(false);
|
||||||
return $"{response.TokenType} {response.AccessToken}";
|
|
||||||
|
// RFC6749 - token_type is case insensitive.
|
||||||
|
// RFC6750 - In Authorization header Bearer should be capitalized.
|
||||||
|
// Fix the capitalization irrespective of token_type casing.
|
||||||
|
switch (response.TokenType?.ToLower())
|
||||||
|
{
|
||||||
|
case "bearer":
|
||||||
|
return $"Bearer {response.AccessToken}";
|
||||||
|
default:
|
||||||
|
return $"{response.TokenType} {response.AccessToken}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user