Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(mobile): send app=harness-mobile on account sign-in

tony7f6871cd1ebb
diff --git a/mobile/lib/viewer/email_code_api.dart b/mobile/lib/viewer/email_code_api.dart
index 0fe8f974d..dd48c57d3 100644
--- a/mobile/lib/viewer/email_code_api.dart
+++ b/mobile/lib/viewer/email_code_api.dart
@@ -53,6 +53,10 @@ class EmailCodeApi {
static const _sendPath = '/api/v1/customers/send-login-verification';
static const _signInPath = '/api/v1/customers/sign-in';
+ /// Names this app to the account API on every `sign-in` call — the code grant and the refresh
+ /// alike. The API accepts it and answers exactly as without it.
+ static const _app = 'harness-mobile';
+
static const _unreachable =
'Could not reach the sign-in service. Check your connection and try again.';
@@ -70,6 +74,7 @@ class EmailCodeApi {
'email': email,
'otp': code,
'grant_type': 'otp',
+ 'app': _app,
});
return _tokens(data) ??
(throw const DirectAuthException('Sign-in returned no access token.'));
@@ -85,7 +90,11 @@ class EmailCodeApi {
try {
res = await _dio.post(
_signInPath,
- data: {'refresh_token': refreshToken, 'grant_type': 'refresh_token'},
+ data: {
+ 'refresh_token': refreshToken,
+ 'grant_type': 'refresh_token',
+ 'app': _app,
+ },
);
} on DioException {
throw const DirectAuthException(_unreachable);
diff --git a/mobile/test/viewer/email_code_api_test.dart b/mobile/test/viewer/email_code_api_test.dart
index a1d31dd98..0146ec3b4 100644
--- a/mobile/test/viewer/email_code_api_test.dart
+++ b/mobile/test/viewer/email_code_api_test.dart
@@ -71,6 +71,7 @@ void main() {
'email': '[email protected]',
'otp': '1234',
'grant_type': 'otp',
+ 'app': 'harness-mobile',
});
expect(tokens.token, 'access-1');
expect(tokens.refreshToken, 'refresh-1');
@@ -163,6 +164,7 @@ void main() {
expect(http.sent.single.body, {
'refresh_token': 'refresh-0',
'grant_type': 'refresh_token',
+ 'app': 'harness-mobile',
});
expect(tokens.token, 'access-1');
});