-
Notifications
You must be signed in to change notification settings - Fork 3
add authentication to requests if required #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: multiplatform-client
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,42 +64,42 @@ public abstract class ApiClientBase { | |
| } | ||
| {{#hasAuthMethods}} | ||
|
|
||
| protected fun HttpRequestBuilder.addAuthentication(apiKeyAuths: List<String>, basicAuths: List<String>, bearerAuths: List<String>, oAuths: List<String>) { | ||
| for (name in apiKeyAuths) { | ||
| val auth = apiKeyAuth[name] ?: throw IllegalStateException("ApiKeyAuth \"$name\" was configured, but not found") | ||
| if (auth.isConfigured) { | ||
| protected fun HttpRequestBuilder.addAuthentication(vararg auths: String) { | ||
| for (name in auths) { | ||
| val auth = apiKeyAuth[name] | ||
| if (auth?.isConfigured == true) { | ||
| auth.configure(this) | ||
| return | ||
| } | ||
| } | ||
| for (name in basicAuths) { | ||
| val auth = basicAuth[name] ?: throw IllegalStateException("HttpBasicAuth \"$name\" was configured, but not found") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| if (auth.isConfigured) { | ||
| for (name in auths) { | ||
| val auth = basicAuth[name] | ||
| if (auth?.isConfigured == true) { | ||
| auth.configure(this) | ||
| return | ||
| } | ||
| } | ||
| for (name in bearerAuths) { | ||
| val auth = bearerAuth[name] ?: throw IllegalStateException("HttpBearerAuth \"$name\" was configured, but not found") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| if (auth.isConfigured) { | ||
| for (name in auths) { | ||
| val auth = bearerAuth[name] | ||
| if (auth?.isConfigured == true) { | ||
| auth.configure(this) | ||
| return | ||
| } | ||
| } | ||
| for (name in oAuths) { | ||
| val auth = oAuth[name] ?: throw IllegalStateException("OAuth \"$name\" was configured, but not found") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above |
||
| if (auth.isConfigured) { | ||
| for (name in auths) { | ||
| val auth = oAuth[name] | ||
| if (auth?.isConfigured == true) { | ||
| auth.configure(this) | ||
| return | ||
| } | ||
| } | ||
| throw IllegalStateException( | ||
| """ | ||
| No valid authentication configured, please configure one of the following: | ||
| API Key Authentication: ${apiKeyAuths.joinToString()} | ||
| HTTP Bearer Authentication: ${apiKeyAuths.joinToString()} | ||
| HTTP Basic Authentication: ${apiKeyAuths.joinToString()} | ||
| OAuth: ${apiKeyAuths.joinToString()} | ||
| API Key Authentication: ${apiKeyAuth.keys.joinToString()} | ||
| HTTP Bearer Authentication: ${bearerAuth.keys.joinToString()} | ||
| HTTP Basic Authentication: ${basicAuth.keys.joinToString()} | ||
| OAuth: ${oAuth.keys.joinToString()} | ||
| """.trimIndent() | ||
| ) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These had the pretty good reason to error on invalid schemas, so I'd like to keep them