Skip to content
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

feat: Token create & delete from CLI #39

Merged
merged 23 commits into from
Feb 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
codekeyz committed Feb 16, 2024

Unverified

This user has not yet uploaded their public signing key.
commit 86f6cdde55fce5090a5947453b2677241dc12fd1
11 changes: 6 additions & 5 deletions packages/globe_cli/lib/src/utils/api.dart
Original file line number Diff line number Diff line change
@@ -238,19 +238,20 @@ class GlobeApi {
});

// create token
var response = _handleResponse(
final response = _handleResponse(
await http.post(_buildUri(createTokenPath), headers: headers, body: body),
)! as Map<String, Object?>;
final token = Token.fromJson(response);

final generateTokenPath = '/orgs/$orgId/api-tokens/${token.uuid}/generate';
logger.detail('API Request: POST $generateTokenPath');
logger.detail('API Request: GET $generateTokenPath');

// get token value
response = _handleResponse(
final tokenValue = _handleResponse(
await http.get(_buildUri(generateTokenPath), headers: headers),
)! as Map<String, Object?>;
return (id: token.uuid, value: response['token'].toString());
)! as String;

return (id: token.uuid, value: tokenValue);
}

Future<void> deleteToken({