Skip to content

Commit da0918a

Browse files
authored
RSDK-12361 - remove location secret code (#443)
* remove location secret code * make format
1 parent d794bbf commit da0918a

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

example/viam_robot_example_app/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ API_KEY_ID=<API KEY ID>
1616
API_KEY=<API KEY>
1717
```
1818

19-
or using location secrets (deprecated, please prefer using API keys!):
20-
21-
```
22-
ROBOT_LOCATION=<ROBOT_LOCATION_URI>
23-
LOCATION_SECRET=<ROBOT_LOCATION_SECRET>
24-
```
25-
26-
Both these fields can be obtained from your robot's `Code Sample` tab on [app.viam.com](https://app.viam.com).
19+
These fields can be obtained from your robot's `Code Sample` tab on [app.viam.com](https://app.viam.com).
2720

2821
## Run
2922

lib/src/robot/client.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ class RobotClientOptions {
4949
..credentials = Credentials.apiKey(apiKey)
5050
..authEntity = apiKeyID;
5151

52-
/// Convenience initializer for creating options with a robot location secret
53-
RobotClientOptions.withLocationSecret(String locationSecret)
54-
: dialOptions = DialOptions()..credentials = Credentials.locationSecret(locationSecret);
52+
/// Convenience initializer for creating options with a robot secret
53+
RobotClientOptions.withRobotSecret(String robotSecret) : dialOptions = DialOptions()..credentials = Credentials.robotSecret(robotSecret);
5554
}
5655

5756
/// {@category Viam SDK}

lib/src/rpc/dial.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ class DialOptions {
7878
/// {@category Viam SDK}
7979
/// The credentials used for connecting to the robot
8080
class Credentials {
81-
/// The type of credential, e.g. 'robot-location-secret', 'api-key'
81+
/// The type of credential, e.g. 'robot-secret', 'api-key'
8282
final String type;
8383

8484
/// The payload of the credential
8585
final String payload;
8686

8787
const Credentials(this.type, this.payload);
8888

89-
/// Convenience initializer for creating credentials of type 'robot-location-secret' with the provided payload.
90-
const Credentials.locationSecret(this.payload) : type = 'robot-location-secret';
89+
/// Convenience initializer for creating credentials of type 'robot-secret' with the provided payload.
90+
const Credentials.robotSecret(this.payload) : type = 'robot-secret';
9191

9292
/// Convenience initializer for creating credentials of type 'api-key' with the provided key as payload.
9393
const Credentials.apiKey(this.payload) : type = 'api-key';

lib/src/viam_sdk_impl.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ class ViamImpl implements Viam {
9797

9898
@override
9999
Future<RobotClient> getRobotClient(Robot robot) async {
100-
final location = await appClient.getLocation(robot.location);
101-
final secret = location.auth.secrets.firstWhere((element) => element.state == SharedSecret_State.STATE_ENABLED);
102100
final parts = await appClient.listRobotParts(robot.id);
103101
final part = parts.firstWhere((element) => element.mainPart);
104-
return RobotClient.atAddress(part.fqdn, RobotClientOptions.withLocationSecret(secret.secret));
102+
return RobotClient.atAddress(part.fqdn, RobotClientOptions.withRobotSecret(part.secret));
105103
}
106104
}

0 commit comments

Comments
 (0)