File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
src/main/scala/algoliasearch Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ abstract class ApiClient(
40
40
throw AlgoliaClientException (" `apiKey` is missing." )
41
41
}
42
42
43
+ private val authInterceptor = new AuthInterceptor (appId, apiKey)
44
+
43
45
private val requester = options.customRequester match {
44
46
case Some (customRequester) => customRequester
45
47
case None =>
@@ -62,7 +64,7 @@ abstract class ApiClient(
62
64
63
65
val builder = HttpRequester
64
66
.builder(options.customFormats.getOrElse(formats))
65
- .withInterceptor(new AuthInterceptor (appId, apiKey) )
67
+ .withInterceptor(authInterceptor )
66
68
.withInterceptor(new UserAgentInterceptor (algoliaAgent))
67
69
.withInterceptor(new RetryStrategy (statefulHosts))
68
70
@@ -89,4 +91,8 @@ abstract class ApiClient(
89
91
override def close (): Unit = {
90
92
Try (requester.close())
91
93
}
94
+
95
+ def setClientApiKey (apiKey : String ): Unit = {
96
+ authInterceptor.setApiKey(apiKey)
97
+ }
92
98
}
Original file line number Diff line number Diff line change @@ -11,12 +11,16 @@ import okhttp3.{Interceptor, Response}
11
11
*/
12
12
private [algoliasearch] class AuthInterceptor (
13
13
applicationId : String ,
14
- apiKey : String
14
+ private var apiKey : String
15
15
) extends Interceptor {
16
16
17
17
private val HeaderApplicationId = " x-algolia-application-id"
18
18
private val HeaderApiKey = " x-algolia-api-key"
19
19
20
+ def setApiKey (newApiKey : String ): Unit = {
21
+ apiKey = newApiKey
22
+ }
23
+
20
24
override def intercept (chain : Interceptor .Chain ): Response = {
21
25
val originalRequest = chain.request()
22
26
val builder = originalRequest.newBuilder()
You can’t perform that action at this time.
0 commit comments