Skip to content

Commit f5a6fc1

Browse files
committed
fix: update tokens after reading/creating client [#244]
1 parent 7fdd029 commit f5a6fc1

File tree

1 file changed

+9
-7
lines changed
  • packages/clerk_auth/lib/src/clerk_api

1 file changed

+9
-7
lines changed

packages/clerk_auth/lib/src/clerk_api/api.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ class Api with Logging {
114114
);
115115
if (resp.statusCode == HttpStatus.ok) {
116116
final body = json.decode(resp.body) as _JsonObject;
117-
return Client.fromJson(body[_kResponseKey]);
117+
final client = Client.fromJson(body[_kResponseKey]);
118+
_tokenCache.updateFrom(resp, client);
119+
return client;
118120
}
119121
return Client.empty;
120122
}
@@ -807,11 +809,10 @@ class Api with Logging {
807809
final resp = await _fetch(
808810
path: path,
809811
headers: _headers(),
810-
params: {
812+
nullableParams: {
811813
if (org case Organization org) //
812814
_kOrganizationId: org.externalId,
813815
},
814-
nullableKeys: [_kOrganizationId],
815816
);
816817
if (resp.statusCode == HttpStatus.ok) {
817818
final body = json.decode(resp.body) as _JsonObject;
@@ -943,12 +944,13 @@ class Api with Logging {
943944
HttpMethod method = HttpMethod.post,
944945
Map<String, String>? headers,
945946
_JsonObject? params,
947+
_JsonObject? nullableParams,
946948
bool withSession = false,
947-
List<String>? nullableKeys,
948949
}) async {
949-
final parsedParams = {...?params}..removeWhere(
950-
(key, value) => value == null && nullableKeys?.contains(key) != true,
951-
);
950+
final parsedParams = {
951+
...{...?params}..removeWhere((k, v) => v == null),
952+
...?nullableParams,
953+
};
952954
final queryParams =
953955
_queryParams(method, withSession: withSession, params: parsedParams);
954956
final uri = _uri(path, params: queryParams);

0 commit comments

Comments
 (0)